PDA

View Full Version : Insert Image after Text in Text Field



Harris
06-22-2023, 02:17 AM
Hi,

I have the following function to insert an image into a Text Field:


Private Sub InsertPicture(filename As String)

With ActiveDocument.Shapes(activeTextbox).TextFrame.textRange
.InlineShapes.AddPicture filename:=filename, _
LinkToFile:=False, SaveWithDocument:=True
End With

End Sub

Now I want to insert the image below the text in the text Field and I guess for that I have to make
use of the 'Range' parameter of the AddPicture function. But I dont know how to do it.

Can someone help me out?

Thanks

gmaxey
06-22-2023, 10:47 AM
Private Sub InsertPicture(filename As String)
Dim oRng As Range
With ActiveDocument.Shapes(1).TextFrame
Set oRng = .TextRange
oRng.Collapse wdCollapseEnd
oRng.InlineShapes.AddPicture filename:=filename, _
LinkToFile:=False, SaveWithDocument:=True
End With

End Sub