Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Location
    Boston, MA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Format Picture (using code) - Help? (2000 SR-1)

    Hello. I'd REALLY appreciate it if someone could help me with this.
    I'm inserting a .jpg with the code:
    Selection.InlineShapes.AddPicture FileName:="<filename>", LinkToFile:=False, SaveWithDocument:=True
    However, when it inserts the picture, if you go to Format Picture, the Layout is set to "In line with text." The users want the picture to be either "Behind text" or "In front of text" but I can't figure out how to change that property with code.

    Anyone have ANY ideas? Thank you very much!

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Format Picture (using code) - Help? (2000 SR-1)

    Well, that was a very ugly problem (the macro recorder disables floating & it's totally different terminology in VBA), but I think I solved it. Try this macro with your filename. HTH --Sam<pre>Option Explicit
    Sub Place16()
    Dim s As Shape
    With Selection.InlineShapes.AddPicture(FileName:= _
    "Cocuments and SettingssbMy DocumentsMy Pictures16.jpg", _
    LinkToFile:=False, SaveWithDocument:=True)
    Set s = .ConvertToShape
    End With
    s.WrapFormat.Type = wdWrapNone
    s.ZOrder msoBringInFrontOfText
    End Sub
    </pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Format Picture (using code) - Help? (2000 SR-1)

    As a footnote to Sam's solution, which I haven't tried, an InlineShape by definition is not in the drawing layer and that's why it doesn't have the option to be separated from the text layer (or whatever you want to call the main meat of the document). Sam is using the ambiguously named .ConvertToShape method to make those options available. (I don't know if this explanation is helpful or even coherent, but I hope it helps.)

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Format Picture (using code) - Help? (2000 SR-1)

    I originally tried the AddPicture method of the Document.Shapes collection, because it looked like I needed a Shape rather than an InlineShape, but this places the Picture at the top of the document and I went crazy trying to move it near the selection. Fortunately, the ConvertToShape (what do you mean "ambiguously"?) method left the picture in the same position as the selection. I'm still trying to understand Word's object model, (how can Redmond call it a model, seem more like a house of straw) so any suggestion are greatly appreciated (but seldom understood)!
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Format Picture (using code) - Help? (2000 SR-1)

    (By ambiguous I meant, it already is a kind of shape, so it should be called .ConvertToThatOtherKindOfShape.)

Posting Permissions

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