P
paul.brown
Hi this module to export a query to Excel works Access/Excel 2000 but
not with Access/Excel 2003. The Module comes up with the error handler
message Please ensure that you have not already got MoIncident.xls
open. and gets to the portion marked **** before it fails.
I have looked around in the help and forums to no avail.
Any guidance will be much appreciated.
Paul
Private Sub CmdMAccInc_Click()
On Error GoTo ErrorHandler
Dim strCurDir As String
'Find Current Directory
strCurDir = CurrentDb.Name
strCurDir = Left(strCurDir, Len(strCurDir) - Len(Dir(strCurDir)))
MsgBox "here"
MsgBox strCurDir
****
'Update spreadsheet with Query Data
DoCmd.TransferSpreadsheet acExport, 8, "qryMOIncident", strCurDir &
"\MoIncident.xls", True
'Open Spreadsheet and allow user to ammend and save as required.
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Open (strCurDir & "MoIncident.xls")
Exit Sub
ErrorHandler:
MsgBox "Please ensure that you have not already got MoIncident.xls
open"
End Sub
not with Access/Excel 2003. The Module comes up with the error handler
message Please ensure that you have not already got MoIncident.xls
open. and gets to the portion marked **** before it fails.
I have looked around in the help and forums to no avail.
Any guidance will be much appreciated.
Paul
Private Sub CmdMAccInc_Click()
On Error GoTo ErrorHandler
Dim strCurDir As String
'Find Current Directory
strCurDir = CurrentDb.Name
strCurDir = Left(strCurDir, Len(strCurDir) - Len(Dir(strCurDir)))
MsgBox "here"
MsgBox strCurDir
****
'Update spreadsheet with Query Data
DoCmd.TransferSpreadsheet acExport, 8, "qryMOIncident", strCurDir &
"\MoIncident.xls", True
'Open Spreadsheet and allow user to ammend and save as required.
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Open (strCurDir & "MoIncident.xls")
Exit Sub
ErrorHandler:
MsgBox "Please ensure that you have not already got MoIncident.xls
open"
End Sub