I
Ian Millward
Dim oXl As Object, oWb As Object
Dim fName As String
After creating a new Excel file with the following code, if I try to
re-export the data and overwrite the previous version, an error is reported
executing the column format routine and I cannot use or delete the Excel
file. Also, I have to shut the server down using Windows Task Manager to use
the spreadsheet.
The routine does not make Excel visible so I am closing the file and
destroying the object variable by code but it leaves the Server active. Any
hints what I am doing wrong?
I am using W2k and Office 2000
//
fName = "C:\Fred.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "QryMain",
fName, True
Set oXl = CreateObject("Excel.Application")
Set oWb = oXl.Workbooks.Open(fName)
'Adjust column widths and make headers bold
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Font.Bold = True
Selection.Columns.AutoFit
Range("A1").Select
oWb.Save
oWb.Close False
Set oWb = Nothing
oXl.Quit
Set oXl = Nothing
End Sub
//
Dim fName As String
After creating a new Excel file with the following code, if I try to
re-export the data and overwrite the previous version, an error is reported
executing the column format routine and I cannot use or delete the Excel
file. Also, I have to shut the server down using Windows Task Manager to use
the spreadsheet.
The routine does not make Excel visible so I am closing the file and
destroying the object variable by code but it leaves the Server active. Any
hints what I am doing wrong?
I am using W2k and Office 2000
//
fName = "C:\Fred.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "QryMain",
fName, True
Set oXl = CreateObject("Excel.Application")
Set oWb = oXl.Workbooks.Open(fName)
'Adjust column widths and make headers bold
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Font.Bold = True
Selection.Columns.AutoFit
Range("A1").Select
oWb.Save
oWb.Close False
Set oWb = Nothing
oXl.Quit
Set oXl = Nothing
End Sub
//