schniggeldorf
Registered User.
- Local time
- Today, 12:45
- Joined
- Jan 7, 2013
- Messages
- 22
Hi:
I have some vba code that previously worked without difficulty. It determines which type of schedule a user wishes to print, then exports the data from the appropriate Access 2003 table into the appropriate Excel 2003 workbook.
However, our IT department just upgraded me to Excel 2010. I copied the Excel 2003 workbook to a Excel 2010 .xlsm workbook, changed the export path specification to reflect the change, and tried to run my code with the new version. However, whenever I attempt this, I now get a "external table is not in the expected format" error.
The relevant code follows. (I'm sorry if this isn't formatted correctly. I couldn't find the formatting directions for this site.) ScheduleExportPath is a constant defined in another module, but I checked to see that it was choosing the path correctly, and it was. PatientScheduleTemplateName and its cousins are likewise constants defined elsewere.
I assume there's some change I need to make in the TransferSpreadsheet statement to reflect the fact that I'm now transferring to Excel 2010 rather than 2003, but I can't figure out what it is.
Sub ExportToExcelSchedule(ScheduleType As String, ScheduleOwner As String, MaxWeeks As Integer)
Dim xlApp As Object
Dim xlWBk As Object
Dim wsParameters As Object
Dim wsSheet As Object
Dim wsWeek As Object
Dim wsFoundSheet As Object
Dim DataRange As Object
Dim i As Integer
Dim rowFirstTime As Integer
Dim rowLastTime As Integer
Dim rowLastData As Long
Dim myRange
Dim strWeek As String
Dim ScheduleTemplateNameConst As String
Dim tblToExport As String
Dim flg As Boolean
Set xlApp = CreateObject("Excel.Application")
'Select appropriate ScheduleTemplateNameConstant & tblToExport
Select Case ScheduleType
Case "Patient"
ScheduleTemplateNameConst = PatientScheduleTemplateName
tblToExport = "tblPatientPrintout"
Case "Provider"
ScheduleTemplateNameConst = ProviderScheduleTemplateName
tblToExport = "tblProviderPrintout"
Case "Equipment"
ScheduleTemplateNameConst = EquipmentScheduleTemplateName
tblToExport = "tblEquipmentPrintout"
Case "Room"
ScheduleTemplateNameConst = RoomScheduleTemplateName
tblToExport = "tblRoomPrintout"
End Select
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, tblToExport, ScheduleExportPath & ScheduleTemplateNameConst, True
Thanks for any help you can provide.
I have some vba code that previously worked without difficulty. It determines which type of schedule a user wishes to print, then exports the data from the appropriate Access 2003 table into the appropriate Excel 2003 workbook.
However, our IT department just upgraded me to Excel 2010. I copied the Excel 2003 workbook to a Excel 2010 .xlsm workbook, changed the export path specification to reflect the change, and tried to run my code with the new version. However, whenever I attempt this, I now get a "external table is not in the expected format" error.
The relevant code follows. (I'm sorry if this isn't formatted correctly. I couldn't find the formatting directions for this site.) ScheduleExportPath is a constant defined in another module, but I checked to see that it was choosing the path correctly, and it was. PatientScheduleTemplateName and its cousins are likewise constants defined elsewere.
I assume there's some change I need to make in the TransferSpreadsheet statement to reflect the fact that I'm now transferring to Excel 2010 rather than 2003, but I can't figure out what it is.
Sub ExportToExcelSchedule(ScheduleType As String, ScheduleOwner As String, MaxWeeks As Integer)
Dim xlApp As Object
Dim xlWBk As Object
Dim wsParameters As Object
Dim wsSheet As Object
Dim wsWeek As Object
Dim wsFoundSheet As Object
Dim DataRange As Object
Dim i As Integer
Dim rowFirstTime As Integer
Dim rowLastTime As Integer
Dim rowLastData As Long
Dim myRange
Dim strWeek As String
Dim ScheduleTemplateNameConst As String
Dim tblToExport As String
Dim flg As Boolean
Set xlApp = CreateObject("Excel.Application")
'Select appropriate ScheduleTemplateNameConstant & tblToExport
Select Case ScheduleType
Case "Patient"
ScheduleTemplateNameConst = PatientScheduleTemplateName
tblToExport = "tblPatientPrintout"
Case "Provider"
ScheduleTemplateNameConst = ProviderScheduleTemplateName
tblToExport = "tblProviderPrintout"
Case "Equipment"
ScheduleTemplateNameConst = EquipmentScheduleTemplateName
tblToExport = "tblEquipmentPrintout"
Case "Room"
ScheduleTemplateNameConst = RoomScheduleTemplateName
tblToExport = "tblRoomPrintout"
End Select
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, tblToExport, ScheduleExportPath & ScheduleTemplateNameConst, True
Thanks for any help you can provide.