Results 1 to 5 of 5
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Covert to shape method fails (Word 2003)

    Does it help if you change

    For Each IShape In objWord.ActiveDocument.InlineShapes
    IShape.ConvertToShape
    Next IShape

    to

    Dim i As Integer
    For i = docWord.InlineShapes.Count To 1 Step -1
    docWord.InlineShapes(i).ConvertToShape
    Next i

    BTW, why don't you create the shapes as floating shapes immediately, instead of creating them as inline shapes and converting them to floating?

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert to shape method fails (Word 2003)

    Could anyone point out the error that makes this code fail the first time at the line:

    IShape.ConvertToShape

    with the message:

    Method 'ConvertToShape' of object 'InlineShape' failed

    BUT
    If I choose DEBUG then press F5 or F8 the routine completes successfully.
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>
    Very long code fragment (>4,000 characters) moved to attachment by HansV

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Covert to shape method fails (Word 2003)

    That worked Hans, thanks.
    I couldn't figure out how to add a Shape directly - the add shape method doesn't seem to allow for the file name of the object you want to insert.
    I guess it is a property of the shape that you set later?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Covert to shape method fails (Word 2003)

    Yes. You can use code like this:
    <code>
    Dim shp As Shape
    Set shp = ActiveDocument.Shapes.AddPicture( _
    FileName:="C:...Logo With URL.jpg", _
    LinkToFile:=False, SaveWithDocument:=True)
    shp.Name = "MyPic1"
    ...
    </code>
    You can specify the position of the shape either in the AddPicture method or later.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Covert to shape method fails (Word 2003)

    Of course. Thanks Hans.
    I was trying to use AddShape - silly me!
    Works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •