PDA

View Full Version : VBA CODE , how to to control where to put the pictures



ElCapitano
02-23-2022, 03:39 AM
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

gmayor
02-23-2022, 05:06 AM
See your other thread re the path. The code starts placing the pictures from the cursor position. Where did you want to put them?

ElCapitano
02-23-2022, 05:17 AM
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