Hello all,
Fairly new dabbling at VBA, working with some existing documents programmed by another person that make extensive use of macros to automatically generate report elements.
We have just upgraded a couple of machines to Win7/Office2010 from Office2007, and am having some temperamental issues copying charts and ranges from Excel into Word on the 2010 machines, despite it all working perfectly on 2007 machines.
Receiving a few different errors at different times (not reliably one or the other)-
1004: Application-defined or object-defined error
or
1004: The specified dimension is not valid for the current chart type
or
4605: This method or property is not available because the Clipboard is empty or not valid
All link variously to the following sets of code, although there are multiple chart objects and ranges (eg BarChart, CompTable etc) that seemingly randomly become isolated.
i is a variable number based on the number of things we are reporting on. What is most puzzling is that the code will execute seemingly random iterations properly without having a problem before failing (eg, stops at i = 1, i = 5, i = 7 etc).
When the error occurs and I go back to excel, all the charts, ranges appear to be on the right sheets and with the right name/label.
So what I can reason out:
-The code isnt fundamentally wrong as it works flawlessly in 2007 and *can* execute some iterations in 2010 before having trouble.
-There may be issues with the copying or clipboard?
-I don't know enough!
The most annoying part is that it isn't coming up with a consistent problem (I can usually troubleshoot/workaround those) but varies without me changing anything. I can isolate the vague area but I'm afraid I don't know enough to figure it out, and several hours of research online hasn't helped.
Can someone at least suggest what I should be looking in to if they can't provide a solution!?
*I've looked at Reference Libraries but had eliminated them after trying a few different options - am I maybe missing something there?
Fairly new dabbling at VBA, working with some existing documents programmed by another person that make extensive use of macros to automatically generate report elements.
We have just upgraded a couple of machines to Win7/Office2010 from Office2007, and am having some temperamental issues copying charts and ranges from Excel into Word on the 2010 machines, despite it all working perfectly on 2007 machines.
Receiving a few different errors at different times (not reliably one or the other)-
1004: Application-defined or object-defined error
or
1004: The specified dimension is not valid for the current chart type
or
4605: This method or property is not available because the Clipboard is empty or not valid
All link variously to the following sets of code, although there are multiple chart objects and ranges (eg BarChart, CompTable etc) that seemingly randomly become isolated.
Code:
Sheets("SortedData").ChartObjects("Piechart" & i).Copy
wrdApp.Selection.Paste
Code:
Sheets("Tables & Barcharts").Select
Range("ComparisonTable" & i).Select
Selection.Copy
wrdApp.Selection.Paste
i is a variable number based on the number of things we are reporting on. What is most puzzling is that the code will execute seemingly random iterations properly without having a problem before failing (eg, stops at i = 1, i = 5, i = 7 etc).
When the error occurs and I go back to excel, all the charts, ranges appear to be on the right sheets and with the right name/label.
So what I can reason out:
-The code isnt fundamentally wrong as it works flawlessly in 2007 and *can* execute some iterations in 2010 before having trouble.
-There may be issues with the copying or clipboard?
-I don't know enough!
The most annoying part is that it isn't coming up with a consistent problem (I can usually troubleshoot/workaround those) but varies without me changing anything. I can isolate the vague area but I'm afraid I don't know enough to figure it out, and several hours of research online hasn't helped.
Can someone at least suggest what I should be looking in to if they can't provide a solution!?
*I've looked at Reference Libraries but had eliminated them after trying a few different options - am I maybe missing something there?
Last edited: