|
-
Jan 20th, 2012, 10:29 AM
#1
Thread Starter
Member
[RESOLVED] Create New Workbook
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.
Last edited by maurice_whittaker; Jan 27th, 2012 at 11:49 AM.
Reason: To remove RESOLVED
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|