1

I wish to copy Excel charts into Word using VBA.

I use a bookmark to position the first chart and that works fine. I wish to position the next chart alongside the first one (i.e. in the middle of the page) and I can't find how to do that.

I've set up a bookmark in the middle of the page but VBA just pastes the chart to the left margin. The Word macro recorder generates no useable code for this operation.

I have no experience with VBA in Word. Can anyone help?

I've tried a variety of options, the one below works for the first chart

'The first chart copies OK to Bookmark "Change"

ws.ChartObjects(1).Copy
doc.Bookmarks("Change").Range.PasteSpecial _
    Link:=False, _
    DataType:=wdPasteEnhancedMetafile, _
    Placement:=wdFloatOverText, _
    DisplayAsIcon:=False

Bookmark DemandChange is in the middle of the page, the second chart pastes on top of the first chart (i.e.at left margin).

ws.ChartObjects(2).Copy
doc.Bookmarks("DemandChange").Select
wd.Selection.PasteSpecial _
    Link:=False, _
    DataType:=wdPasteEnhancedMetafile, _
    Placement:=wdFloatOverText, _
    DisplayAsIcon:=False
1
  • Could you post a picture of how you want the charts ordered? Commented Jun 20, 2019 at 14:23

1 Answer 1

1

The issue you are having relates to the Placement property. You have set it to wdFloatOverText which means that it will be anchored to the bookmark but not sit next to it. To place the two charts side by side you need the chart to be inline.

doc.Bookmarks("Change").Range.PasteSpecial _
    Link:=False, _
    DataType:=wdPasteEnhancedMetafile, _
    Placement:=wdInline, _
    DisplayAsIcon:=False
Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks for replying to my question. I will try your proposal but in the meantime I've found that setting up tables in my Word document allows me to paste to specific cells in the table and resize the inline shape appropriately. This works extremely well for my needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.