The code below is called from an Access (XP SP3) database, and it successfully creates a “False.xls” spreadsheet in MyDocuments, just exactly as I want EXCEPT: the name is not what I selected and the path is not what I had asked for ! . I searched this forum and found a message thread, specifically message 280839 that indicated that Torquemada had encountered this in 2003, and JohnBF helped him, but I don’t think the circumstances are exactly the same as mine. Here is my entire code for what I want to do, and if anything jumps out at you, any comments will be welcome:
Public Function SpawnWorkbook()
On Error GoTo SpawnWkbk_err
Dim xlApp As New Excel.Application
Dim NewBook As Excel.Workbook
Set xlApp = CreateObject(“excel.Application”)
Set NewBook = xlApp.Workbooks.Add(Template:=”C:Documents and SettingsmeDesktopMySpreadsheet.xls”)
With NewBook
.SaveAs FileName = “c:tempBlapSales.xls”
End With
SpawnWkbk_exit:
NewBook.Close
Set NewBook = Nothing
xlApp.Quit
Set xlApp = Nothing
Exit Function
SpawnWkbk_err:
MsgBox CStr(Err.Number) & “: ” & Err.Description
GoTo SpawnWkbk_exit
End Function
* I might add that the template is just another spreadsheet, I don’t know if it needs to be saved explicitely as a template? — just in case it matters.
thx
Pat