Error exporting to Excel after 2016 upgrade (1 Viewer)

MS1234

Registered User.
Local time
Today, 07:39
Joined
Nov 28, 2016
Messages
17
Hi I have a database that's been working fine in Access 2013 but since the upgrade to Access 2016 I am getting an error in the VBA code that exports to excel.

The error is:
Unexpected error occurred: Type mismatch - Number: 13

Below is a snippet of the VBA code, I trapped the error to the specific line noted:

Sub MonthlyReport(xlWs As Excel.Worksheet, xlRng As Excel.Range)

Dim db As DAO.Database
Dim iRow As Integer

Set db = Access.CurrentDb()

iRow = 1

Set xlRng = xlWs.Cells(iRow, 1) '**THIS LINE CAUSES THE ERROR
With xlRng
.Value = "Supplier"
.Font.Bold = True
.Font.Color = vbBlack
.Font.Size = 10
.Font.Underline = True
End With


Can anybody explain why this is happening.
Thanks
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:39
Joined
Feb 28, 2001
Messages
27,142
Check for missing or broken references to the Excel library. Since this error would break on the named line, at that point you should be able to immediately open Tools >> References to verify that you still have a reference to the Excel library.

Normally, references would be updated automatically the first time you open the database with the new version of Access, but we have seen some other complaints about a "ragged" upgrade that doesn't catch the references for some reason.

Since the references are kept in the registry, if your site has strict rules in place about performing registry updates, you could be running afoul of security rules on registry mods, which would interfere with the auto-correction of the references. But since we can't see your site, we won't know. That's a question you would have to ask of your network managers.
 

MS1234

Registered User.
Local time
Today, 07:39
Joined
Nov 28, 2016
Messages
17
Thank you doc man, turns out it was indeed references, I removed the Excel 2016 reference, added it back, everything worked.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:39
Joined
Feb 28, 2001
Messages
27,142
Great! Glad I could point the way.
 

Users who are viewing this thread

Top Bottom