G
Guest
Hi, When I run the following code, I see this error:
"Run-Time error '91': Object variable with block variable
not set"
Would someone be able to tell me what I'm doing wrong?
Thankc!
Dim z As Integer
Dim SheetCount As Integer
Dim SheetName(100) As String
Dim MessageText As String
Dim XLApp As Object
Set XLApp = GetObject(, "Excel.Application")
XLApp.Visible = True
XLFile = strInputFileName
SheetCount = XLApp.ActiveWorkbook.Sheets.Count
For z = 1 To SheetCount
SheetName(z) = XLApp.ActiveWorkbook.Sheets(z).Name
MessageText = MessageText & z & ".) " & SheetName(z) & " "
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel8, XLApp.ActiveWorkbook.Sheets
(z).Name, XLFile, True, SheetName(z)
Next z
"Run-Time error '91': Object variable with block variable
not set"
Would someone be able to tell me what I'm doing wrong?
Thankc!
Dim z As Integer
Dim SheetCount As Integer
Dim SheetName(100) As String
Dim MessageText As String
Dim XLApp As Object
Set XLApp = GetObject(, "Excel.Application")
XLApp.Visible = True
XLFile = strInputFileName
SheetCount = XLApp.ActiveWorkbook.Sheets.Count
For z = 1 To SheetCount
SheetName(z) = XLApp.ActiveWorkbook.Sheets(z).Name
MessageText = MessageText & z & ".) " & SheetName(z) & " "
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel8, XLApp.ActiveWorkbook.Sheets
(z).Name, XLFile, True, SheetName(z)
Next z