Import from Excel Issue

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!
 
J

John Nurick

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.
 
S

Sarah

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.
.
 
B

bbttyy

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top