I'm trying to let users open an Excel file from an Access2000 database through a command button.
The code below produces an Excel session where nothing in the workbook can be selected for a (variable length) while, and persistant attempts lead to a
"Program Error" EXCEL.exe has generated errors...
All menus in Excel are accessible, but have no effect, during this time. Trying to close Excel causes the error. Waiting for a WHILE results in a stable Excel.
Ideas anyone?
Note that the base code comes from the Access command button wizard. The save problem occurs with ANY xls file.
I'm running Office 2K, on Win2K, and about to test on XPHome...
The code below produces an Excel session where nothing in the workbook can be selected for a (variable length) while, and persistant attempts lead to a
"Program Error" EXCEL.exe has generated errors...
All menus in Excel are accessible, but have no effect, during this time. Trying to close Excel causes the error. Waiting for a WHILE results in a stable Excel.
Ideas anyone?
Code:
Private Sub ButOpenXLS_Click()
Dim ExcelSheet, ExcelApp As Object
Dim FileName As String
FileName = Me![BoxFileName].Value
DoCmd.Close acForm, "FMessagesFinishedMCR"
Set ExcelSheet = GetObject(FileName)
Set ExcelApp = ExcelSheet.Parent
' Make Excel visible through the Application object.
ExcelApp.Visible = True
' Make 1st worksheet visible.
ExcelSheet.Windows(1).Visible = True
Set ExcelSheet = Nothing
Set ExcelApp = Nothing
End Sub
Note that the base code comes from the Access command button wizard. The save problem occurs with ANY xls file.
I'm running Office 2K, on Win2K, and about to test on XPHome...