none
Problems with ShapeRange.Height (Word VBA) RRS feed

  • Question

  • I'm having trouble setting the height for a ShapeRange (Chart) that I copied programmatically into Word from Excel. As below, I assign a height to the ShapeRange object, but my assignment does not "stick". There is no error, triggered, but the assignment is simply ignored when I re-open the Word document. 

                Set chrt = ws.ChartObjects(1)                        'Excel Chart

                Set rng = wDoc.Bookmarks("ch2").Range      'A bookmarked range in the Word Doc
                chrt.Copy
                .Bookmarks("ch2").Range.PasteSpecial , , , , DataType:=wdPasteEnhancedMetafile
                rng.ShapeRange(1).Height = 130
                rng.ShapeRange(1).Width = 175

    When I check the height of the object I pasted in, it is 117.85 (should be 130). I confirmed also this is not a scaling issue.

    Any ideas? Tks!


    DragonForest

    Thursday, April 26, 2012 9:58 AM

Answers

  • Turns out, if I specify wdInLine in .PasteSpecial, it works now. (The documentation said that wdInLine was the default for the Placement parameter, but I needed to explicitly set the parameter to wdInLine). 

    DragonForest

    Thursday, April 26, 2012 10:54 AM

All replies

  • Turns out, if I specify wdInLine in .PasteSpecial, it works now. (The documentation said that wdInLine was the default for the Placement parameter, but I needed to explicitly set the parameter to wdInLine). 

    DragonForest

    Thursday, April 26, 2012 10:54 AM
  • Thanks for your sharing and have a nice day.

    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 30, 2012 5:33 AM
    Moderator