[RESOLVED] Create New Workbook
:check:Firstly, thank you to Si; I made progress with the Long Path problem but I can't see it on here to set it RESOLVED.
I am in deeper water now in trying to Create a new workbook. This coding has been working fine for months but is now giving error "Type of file not consistent with its extension, (.xls here). The coding I am using is as below & I only copied this without understanding it properly.
Create_New_Workbook MyBook ' Create a new W/Book and name it MyBook
Workbooks.Open Filename:=MyBook ' now open it.
ActiveWorkbook.Save
ActiveWindow.Close
Private Sub Create_New_Workbook(MyBook As String)
Dim xlsApp As Excel.Application
Set xlsApp = Excel.Application
With xlsApp
' .Show Excel
.Visible = True
' Create New Workbook
.Workbooks.Add
.ActiveWorkbook.Worksheets(1).Range("A3") = "Hello" ' This just avoids a possible error by saving an empty Book
.ActiveWorkbook.Close SaveChanges:=True, Filename:=MyBook, Routeworkbook:=False
End With
Exit Sub
End Sub
I had assumed that the xlsApp above determined an xls file and I am very puzzled as to why it should work well and then badly. Any help would be much appreciated.
Re: [RESOLVED] Create New Workbook
vb6 (visual basic 6) is for creating stand alone programs (exe files)
vb 6.3 or 6.5 etc (depending on the application hosting it) are all VBA (visual basic for applications)
and depending on the application hosting, as to what objects and methods are natively available to it, from any application you can automate other applications
much of the code that will run in vb6 can run in VBA and vice versa, but some of the objects would need to be created when required
vba queries should be posted in office development forum, rather than the VB6 forum, even though in many cases the answer would be the same, but specifically queries regarding application objects are more likely to get responses in office development
Re: [RESOLVED] Create New Workbook
Thanks again Pete, I am self-taught and I don't think the teacher was all that good! I saw your reply too late to avoid posting in the wrong place. I did remember the code tags though!
Re: [RESOLVED] Create New Workbook
doing it right helps to get best response
generally i reply to any in this forum first, then the vb6
probably a moderator will move in due course