Link to home
Start Free TrialLog in
Avatar of COACHMAN99
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
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of COACHMAN99
COACHMAN99

ASKER

Thanks HainKurt
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Open(spath & "\" & sFileName)  ' an xls file

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?
Avatar of Bill Prew
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
Also, you might try making sure error trapping is being intercepted by adding the following line just before that code for a test.

    On Error Goto 0
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Open(spath & "\" & sFileName)  ' an xls file

Open in new window


»bp
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.Application")
    'Set xlBook = xlApp.Workbooks.Open("L:\Backup\AAPressedMetal\I10000C153J64341D080105.xlsx")
    Set xlBook = xlApp.Workbooks.Open("L:\Backup\AAPressedMetal\book1.xlsx")
exitsub:
    Exit Sub
err1:
    MsgBox Err.Number & "   " & Err.Description
    Resume exitsub
End Sub
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
See my last comment for a fix...


»bp
works great thanks.
thanks guys
Welcome.


»bp
Thanks for the responds!!