I'm trying to output some text into an Excel file from Access and then export table data right below it. When I do this the text is written but it gives this error when trying to export the table data:
run-time error 3010
Table 'PATIENT_IND_CLAIM_LEDGER$A3:AZ99' already exists
This is my code:
Dim objExcel As EXCEL.Application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.ADD
objExcel.Visible = False
objExcel.Range("A1") = "GROUP:"
objExcel.Range("B1") = GROUPNAME
objExcel.Sheets(1).NAME = "PATIENT_IND_CLAIM_LEDGER"
objExcel.DisplayAlerts = False
objExcel.Workbooks(1).SaveAs (strPath)
objExcel.DisplayAlerts = True
objExcel.Quit
Set objExcel = Nothing
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "PATIENT IND CLAIM LEDGER", strPath, True, "PATIENT_IND_CLAIM_LEDGER!A3:AZ99"
strPath is just the path/filename.
I don't understand -- the file is created and the text is written only to the first row -- why won't it then output the data dump starting at cell A3 instead of giving me this error?
thanks in advance
any help is greatly appreciated!
run-time error 3010
Table 'PATIENT_IND_CLAIM_LEDGER$A3:AZ99' already exists
This is my code:
Dim objExcel As EXCEL.Application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.ADD
objExcel.Visible = False
objExcel.Range("A1") = "GROUP:"
objExcel.Range("B1") = GROUPNAME
objExcel.Sheets(1).NAME = "PATIENT_IND_CLAIM_LEDGER"
objExcel.DisplayAlerts = False
objExcel.Workbooks(1).SaveAs (strPath)
objExcel.DisplayAlerts = True
objExcel.Quit
Set objExcel = Nothing
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "PATIENT IND CLAIM LEDGER", strPath, True, "PATIENT_IND_CLAIM_LEDGER!A3:AZ99"
strPath is just the path/filename.
I don't understand -- the file is created and the text is written only to the first row -- why won't it then output the data dump starting at cell A3 instead of giving me this error?
thanks in advance
any help is greatly appreciated!