AOB
Well-known Member
- Joined
- Dec 15, 2010
- Messages
- 660
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
Hi there,
Bit of a head-scratcher - I have an Access database which uses Excel for reporting purposes. The database was written in Access 2007 and has been in use for a number of years without issue. For clarity, it's a straightforward split database, backend on a network drive, individual frontends on local desktops, in .accde format.
Recently, a number of users have upgraded to Office 2013 and, while the database is generally still functional, the reporting aspect is falling over. The users who continue to use Office 2007 have reported no issues
I've debugged the code on a machine with Office 2013 and discovered that the first error occurs on a line that looks something like this :
So basically taking two adjacent cells and merging them - fairly straightforward stuff. Causes no problems in 2007, but in 2013 it throws a run-time error 1004 : "Application-defined or object-defined error"
But that's unusual because there's nothing wrong with that code? I use late-binding on my deployed code so "sht" is declared as a generic object, as is the Excel Application and any / all associated objects and constants. Plus, at the point of this particular line, Excel has long since been opened and lots of other actions have taken place - so I'm struggling to understand why this particular line would suddenly cause a problem?
Stranger still : In the deployed solution, the reporting process uses a hidden instance of Excel, so the user is spared from seeing all the background work, and then it either displays the instance at the end, or saves the finished workbook for further action, whatever that may be. While I was debugging the above, I made the Excel Application visible again (so I could confirm that everything else to that point had actually taken place, and more importantly, that the line of code in question made sense, i.e. that there was such a range available to be merged etc. etc.)
Once I had made the instance of Excel visible again, and stepped through the line above - no error! I made no changes to the code nor to the workbook it was working on (other than visibility) and suddenly there was no issue. The rest of the code ran without incident.
Anybody have any suggestions as to what on earth is going on?
Thanks!
AOB
Bit of a head-scratcher - I have an Access database which uses Excel for reporting purposes. The database was written in Access 2007 and has been in use for a number of years without issue. For clarity, it's a straightforward split database, backend on a network drive, individual frontends on local desktops, in .accde format.
Recently, a number of users have upgraded to Office 2013 and, while the database is generally still functional, the reporting aspect is falling over. The users who continue to use Office 2007 have reported no issues
I've debugged the code on a machine with Office 2013 and discovered that the first error occurs on a line that looks something like this :
Code:
sht.Range("A1").Resize(, 2).Merge
So basically taking two adjacent cells and merging them - fairly straightforward stuff. Causes no problems in 2007, but in 2013 it throws a run-time error 1004 : "Application-defined or object-defined error"
But that's unusual because there's nothing wrong with that code? I use late-binding on my deployed code so "sht" is declared as a generic object, as is the Excel Application and any / all associated objects and constants. Plus, at the point of this particular line, Excel has long since been opened and lots of other actions have taken place - so I'm struggling to understand why this particular line would suddenly cause a problem?
Stranger still : In the deployed solution, the reporting process uses a hidden instance of Excel, so the user is spared from seeing all the background work, and then it either displays the instance at the end, or saves the finished workbook for further action, whatever that may be. While I was debugging the above, I made the Excel Application visible again (so I could confirm that everything else to that point had actually taken place, and more importantly, that the line of code in question made sense, i.e. that there was such a range available to be merged etc. etc.)
Once I had made the instance of Excel visible again, and stepped through the line above - no error! I made no changes to the code nor to the workbook it was working on (other than visibility) and suddenly there was no issue. The rest of the code ran without incident.
Anybody have any suggestions as to what on earth is going on?
Thanks!
AOB
Last edited: