Import from Excel Issue

  • Thread starter Thread starter Sarah
  • Start date Start date
S

Sarah

A user of mine is having issues importing from Excel and
I cannot debug. OfficeXP, Access2000, Excel(8).

Here is the code, which for the life of me I cannot
figure out what is not working:

Dim myXL As Excel.Application
Dim myWB As Workbook
Dim myWS As Worksheet

Set myXL = GetObject(, "Excel.Application")
****at this poing myXL is valid

strFullName = Me.txtDefaultPath.Value
Set MyWB = myXL.Workbooks.Open(strFullName)
Set myWS = MyWB.Worksheets(1)
****at this point, myWB and myWS are equal to Nothing.
Can't figure out why. Any help is appreciated. Thanks!
 
Hi Sarah,

This would happen if error handling has been turned off with
On Error Resume Next
and strFullName is not the filespec of an Excel workbook.

If that's not the problem, try using
Set myXL = CreateObject("Excel.Application")
If that works, it suggests there's something odd about the running
instance of Excel that's being found by the GetObject() call.
 
Thank you. In fact, error handling was turned off. Of
course there was also an issue with the way the "get UNC
path" was retreiving the spreadsheet, which inadvertently
effected this import process.

Thanks for your reply.
-----Original Message-----
Hi Sarah,

This would happen if error handling has been turned off with
On Error Resume Next
and strFullName is not the filespec of an Excel workbook.

If that's not the problem, try using
Set myXL = CreateObject("Excel.Application")
If that works, it suggests there's something odd about the running
instance of Excel that's being found by the GetObject() call.
A user of mine is having issues importing from Excel and
I cannot debug. OfficeXP, Access2000, Excel(8).

Here is the code, which for the life of me I cannot
figure out what is not working:

Dim myXL As Excel.Application
Dim myWB As Workbook
Dim myWS As Worksheet

Set myXL = GetObject(, "Excel.Application")
****at this poing myXL is valid

strFullName = Me.txtDefaultPath.Value
Set MyWB = myXL.Workbooks.Open(strFullName)
Set myWS = MyWB.Worksheets(1)
****at this point, myWB and myWS are equal to Nothing.
Can't figure out why. Any help is appreciated. Thanks!

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
.
 
Sarah said:
A user of mine is having issues importing from Excel and
I cannot debug. OfficeXP, Access2000, Excel(8).

Here is the code, which for the life of me I cannot
figure out what is not working:

Dim myXL As Excel.Application
Dim myWB As Workbook
Dim myWS As Worksheet

Set myXL = GetObject(, "Excel.Application")
****at this poing myXL is valid

strFullName = Me.txtDefaultPath.Value
Set MyWB = myXL.Workbooks.Open(strFullName)
Set myWS = MyWB.Worksheets(1)
****at this point, myWB and myWS are equal to Nothing.
Can't figure out why. Any help is appreciated. Thanks!
 
Back
Top