Shape manipulating

lubostlubost Member Posts: 623
Hello,
I have following piece of code:

Name DataType Subtype Length
Shape Automation 'Microsoft Word 12.0 Object Library'.Shape
Range Automation 'Microsoft Word 12.0 Object Library'.Range
wdApp Automation 'Microsoft Word 12.0 Object Library'.Application
wdDoc Automation 'Microsoft Word 12.0 Object Library'.Document
LinkToFile Boolean
SaveWithDocuments Boolean
msoTrue Integer

msoTrue := 1;
wdApp.ActiveDocument.Shapes.Item(msoTrue).Select;
Range := wdApp.Selection.Range;
Shape := wdDoc.Shapes.AddPicture('e:\CK.bmp', LinkToFile, SaveWithDocuments, Range);

My word document contains placeholder shape (index = 1) and this code should replace this placeholder with relevant picture. But this way doesnt work.
I tried insert relevant picture as a new shape, but then I have to manipulate properties to set the position and layout of this picture. In this way I cann't see properties (or I don't know which one) to use.

Any recommendation will be usefull
Thanks

Answers

  • lubostlubost Member Posts: 623
    Hello,

    Playing with macro in Word I have found solution:

    Name DataType Subtype Length
    DocSelection Automation 'Microsoft Word 12.0 Object Library'.Selection


    Range := wdApp.ActiveDocument.Range(DocStart, DocEnd);
    Shape := wdDoc.Shapes.AddPicture('e:\CK.bmp', LinkToFile, SaveWithDocuments, Range);
    Shape.Select;
    DocSelection := wdApp.Selection;
    DocSelection.ShapeRange.ScaleWidth(0.33, DocStart, DocStart);
    DocSelection.ShapeRange.Left := 360;
    DocSelection.ShapeRange.Top := 50;
    msoTrue := -1;
    Shape.LockAspectRatio(msoTrue);

    Thanks everyone who started thinking
Sign In or Register to comment.