My aim is a macro that copies all charts/pictures from an Excel worksheet into a Word document. Dave H wrote this macro (ChartToDocument2 in word2.xls) which works for him not for me. The results I get are shown in Result.doc
Can anyone figure out why?
The code may error out if you are running Word XP, if so click the 'Debug' button and this line from the VBA should be highlighted :-
' Reference existing instance of Word
Set WDApp = GetObject(, "Word.Application.9")
' Reference active document
Set WDDoc = WDApp.ActiveDocument
' Reference active slide
Change the application.9 to application.10 for XP then save and re-run the code.
When i tried it copied all 5 charts from Excel into Word.
Hope this helps,
Another approach might be to re set the references in the profile to VBE on the VBA side through adding the Word.Application9 to your list
Word 9 / 10 / 11 object library
MS Office Compatible
These should link up as you require subject to your Word / Excel versions. Or you can Edit as the earlier post suggest, which might be easier.
Kindest possible regards
Jack in the UK
I am using Word and Excel 2000. The macro does run, but when the pictures load onto the Clipboard only 2 out of 6 (including the button control) have any content when pasted onto the Word document (and the graph that does is not pasting correctly).
The Clipboard toolbar shows either 4 out of 6 or 6 out of 6 the first time it runs, and continues to fill up each time it runs(and eventually causes the macro to fall over).
Just wanted to show you the References dialog box to make sure it is clear what I have (the network path given for "Missing:Microsoft Word 10.0 Object Library" does not contain a file of that name, but I presume as I am running Word 9.0 this is not relevant). Attached to the end of Result1.doc are screenshots showing before and after I alter them.
Many thanks for your help with this - I feel like it works for everyone else but not me!