Hi, this forum has been incredibly helpful in the past, I just hope I can get some help now.
I have a workbook that builds a word based report from data. The code below was working fine for years then I believe IT upgraded our version of Office to 2010 it appears to have brought about this failure.
This particular portion of the word report contains a few tables, and approximately 6 or so charts. The problem occurs when pasting the "Chart 6" onto the second page in the Word doc. The crazy thing is right above the code in red below is the code that completes the same process for "Chart 8" which is fine.
The only difference between the charts is Chart 6 is a bar graph, whereas Chart 8 is a line graph. I just don't know why it is now throwing the 1004 error. Any ideas?
Set theChart = Sheets("Electric Util His").ChartObjects("Chart 8")
theChart.Chart.ChartArea.Copy
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="Chart1a")
With wdInfo
.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
wdFloatOverText, DisplayAsIcon:=False
End With
With wdDoc.Shapes(wdDoc.Shapes.Count)
.LockAspectRatio = msoFalse
.Height = 340 '344
.Width = 514 '518.16
End With
Set myNamed = Sheets("Electric Util His").Range("Table2")
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="Table2")
myNamed.Copy
wdInfo.PasteSpecial link:=False, _
DataType:=2, _
Placement:=0, DisplayAsIcon:=False
Set theChart = Nothing
Set wdInfo = Nothing
'Application.Wait (Now + TimeValue("0:00:10"))
Set theChart2 = Sheets("Electric Util His").ChartObjects("Chart 6")
theChart2.Chart.ChartArea.Copy
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="Chart2a")
wdInfo.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
wdFloatOverText, DisplayAsIcon:=False
With wdDoc.Shapes(wdDoc.Shapes.Count)
.LockAspectRatio = msoFalse
.Height = 317.54 '344
.Width = 518.16 '518.16
End With
Set myNamed = Sheets("Billing Profile").Range("BillProfile1Top")
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="ProfileTop")
myNamed.Copy
With wdInfo
.PasteSpecial link:=False, DataType:=wdPasteMetafilePicture, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
With Sheets("Billing Profile")
With .Shapes.Range(Array("Chart 4", "Chart 3")).Group
.Copy
.Ungroup
End With
End With
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="ProfileBottom")
With wdInfo
.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
Set myNamed = Sheets("Billing Profile").Range("BillProfile2Top")
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="ProfileTop2")
myNamed.Copy
With wdInfo
.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
Select Case bPeakGraph
Case True
With Sheets("Billing Profile")
With .Shapes.Range(Array("Chart 7", "Chart 8", "Chart 10")).Group
.Copy
.Ungroup
End With
End With
Case False
With Sheets("Billing Profile No On-Peak")
With .Shapes.Range(Array("Chart 7", "Chart 10")).Group
.Copy
.Ungroup
End With
End With
End Select
Set wdInfo = wdDoc.GoTo(What:=wdGoToBookmark, Name:="ProfileBottom2")
With wdInfo
.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
Set myNamed = Nothing
Set wdInfo = Nothing
Set txtCoName1 = Nothing
Set txtCoName2 = Nothing
Set txtECIUnit = Nothing
Set txtEUIUnit = Nothing
Set objCoName = Nothing
Set objECIUnit = Nothing
Set objEUIUnit = Nothing
Set theChart = Nothing
Set theChart2 = Nothing
Bookmarks