Consulting

Results 1 to 7 of 7

Thread: Inserting multiple pictures in word document

  1. #1

    Inserting multiple pictures in word document

    Hi ,

    When I am trying to insert multiple images to a word document using vba, latest one is getting inserted first. i.e, I have inserted images in this order img1, img2,img3.

    But, in document, images are placed in this order " img3, img2, img1". can anyone help on this?

    Thanks in advance,
    Magesh...

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    Where is your code?
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Hi Max, My code is so simple, am just calling the below sub each time to insert image.

    Sub addImage (wrdDoc As Word.Document, path As String)

    wrdDoc.InlineShapes.AddPicture path

    End Sub

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    Sub addImage(wrdDoc As Word.Document, path As String)
    Dim oRng As Range
      Set oRng = wrdDoc.Range
      oRng.Collapse wdCollapseEnd
      wrdDoc.InlineShapes.AddPicture path, , , oRng
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    Thanks Greg. It works Fine.

  7. #7
    Thanks Paul. Yeah.. this is really an interesting and helpful.

Tags for this Thread

Posting Permissions

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