VBA Code - Pasting Pictures from Excel into Word

C

Cush

I am using Excel to automate the creation of a simple report in Word. Due to
limited stack space I've had to copy my charts in Excel as pictures. When I
then try to copy and paste these pictures into a Word document as part of the
automation, the picture doesn't stay where I pasted it in the report.

Does anyone have the code that can be used in Excel to paste a picture in
Word and have it stay in the same place? The other picture formatting (ex.
wordwrap) specifications seem to work properly. I'm just having problems
with the picture moving with the text written after it's pasted. I'm working
in Excel and Word version 11 (2003) on XP.

The code I am using works for Word version 9, but doesn't work for Word
version 11. Here it is:

appWord.Selection.TypeParagraph
AppActivate "Microsoft Excel"
Sheets("Congress_Charts").Select
ActiveSheet.Shapes("Report1 - Pic01").Select
Selection.Copy
appWord.Selection.ParagraphFormat.Alignment = 1
appWord.Selection.PasteSpecial Link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
appWord.Selection.MoveRight Count:=1

appWord.Selection.ParagraphFormat.SpaceAfter = 20
appWord.Selection.ParagraphFormat.SpaceBefore = 10
appWord.Selection.TypeParagraph
appWord.Selection.ParagraphFormat.Alignment = 3
appWord.Selection.TypeText _
"We need to invest in high schools..."


Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top