COACHMAN99
asked on
opening xls using vba with office 2016
Hi Folks,
We have some vba code that opens xls files using an instance of Excel (late binding).
This worked fine with Office 2010 (and prior versions) but with not with Office 2016.
There are no error messages, just a blank workbook.
Navigating to, and opening the file directly from Excel or Explorer works fine.
The code doesn't use any of the optional arguments, and neither 'format' or 'origin' seem applicable.
Any suggestions would be welcome.
thanks
We have some vba code that opens xls files using an instance of Excel (late binding).
This worked fine with Office 2010 (and prior versions) but with not with Office 2016.
There are no error messages, just a blank workbook.
Navigating to, and opening the file directly from Excel or Explorer works fine.
The code doesn't use any of the optional arguments, and neither 'format' or 'origin' seem applicable.
Any suggestions would be welcome.
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No reason that shouldn't work in 2016. What do spath and sFileName contain?
If you replace the actual file (saving it someplace for a test) with a simple newly created and saved file with the same name and maybe one cell of data, does that then open? If yes, then it's the file. If no, then it's not the file, try a different folder perhaps (maybe a permission issue).
»bp
If you replace the actual file (saving it someplace for a test) with a simple newly created and saved file with the same name and maybe one cell of data, does that then open? If yes, then it's the file. If no, then it's not the file, try a different folder perhaps (maybe a permission issue).
»bp
Also, you might try making sure error trapping is being intercepted by adding the following line just before that code for a test.
»bp
On Error Goto 0
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(spath & "\" & sFileName) ' an xls file
»bp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi All,
the same code doesn't open xls or a new xlsx in 2013 or 2016. error# 0 , no description
Private Sub Command0_Click()
On Error GoTo err1
Set xlApp = CreateObject("Excel.Applic ation")
'Set xlBook = xlApp.Workbooks.Open("L:\B ackup\AAPr essedMetal \I10000C15 3J64341D08 0105.xlsx" )
Set xlBook = xlApp.Workbooks.Open("L:\B ackup\AAPr essedMetal \book1.xls x")
exitsub:
Exit Sub
err1:
MsgBox Err.Number & " " & Err.Description
Resume exitsub
End Sub
the same code doesn't open xls or a new xlsx in 2013 or 2016. error# 0 , no description
Private Sub Command0_Click()
On Error GoTo err1
Set xlApp = CreateObject("Excel.Applic
'Set xlBook = xlApp.Workbooks.Open("L:\B
Set xlBook = xlApp.Workbooks.Open("L:\B
exitsub:
Exit Sub
err1:
MsgBox Err.Number & " " & Err.Description
Resume exitsub
End Sub
ASKER
Hi folks,
it opening Excel but not the file, and not displaying.
I was hoping someone had a quick fix based on a similar experience
Please leave it with me for now.
thanks
it opening Excel but not the file, and not displaying.
I was hoping someone had a quick fix based on a similar experience
Please leave it with me for now.
thanks
See my last comment for a fix...
»bp
»bp
ASKER
works great thanks.
ASKER
thanks guys
Welcome.
»bp
»bp
Thanks for the responds!!
ASKER
Set xlApp = CreateObject("Excel.Applic
Set xlBook = xlApp.Workbooks.Open(spath
I can try to get the sample file. will have to edit it to delete sensitive data. This may change the 'internals' and negate the issue.
Do you have Excel 2016 on your machine?