Consulting

Results 1 to 3 of 3

Thread: VBA CODE , how to to control where to put the pictures

  1. #1

    VBA CODE , how to to control where to put the pictures

    So this code will put pictures from a specific folder in your word. You have any ideea how can i control where to put the pictures ? what I must change in the code...


    Sub GetPictures()
        Dim sPic As String
        Dim sPath As String
    sPath = "c:\myfolder"
        sPic = Dir(sPath & "*.jpg")
    Do While sPic <> ""
            Selection.InlineShapes.AddPicture _
              FileName:=sPath & sPic, _
              LinkToFile:=False, SaveWithDocument:=True
            sPic = Dir
            Selection.TypeParagraph
            Selection.TypeParagraph
        Loop
    End Sub
    Last edited by Aussiebear; 02-23-2022 at 03:36 PM. Reason: Added code tags to supplied code

  2. #2
    See your other thread re the path. The code starts placing the pictures from the cursor position. Where did you want to put them?
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Quote Originally Posted by gmayor View Post
    See your other thread re the path. The code starts placing the pictures from the cursor position. Where did you want to put them?
    I want to put them after a specific text. example: lion - to put the picture with the name lion

Posting Permissions

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