KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
how do i programatically add an image using VBA to a word document. I've tried adding a bookmark to the word document and tried adding the image, but it always adds to the top of the form rather than the bookmark area. Should i persevere with the bookmark or is there another way to add the image? See my code below: Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Set wrdApp = CreateObject("Word.Application") Dim objWdRange As Word.Range Dim GraphImage As String Dim shortString As String shortString = Range("short").Value GraphImage = "http://xxx.xxxxx.com/xxx/xxx.png?instrument=Image.png" wrdApp.Visible = True Set wrdDoc = wrdApp.Documents.Open("C:\Program Files\My Dropbox\dailystrategy.doc") Set objWdRange = wrdDoc.Content With wrdDoc If wrdDoc.Bookmarks.Exists("shortString ") Then wrdDoc.Bookmarks("shortString ").Range.Text = shortString End If If wrdDoc.Bookmarks.Exists("GraphImage") Then wrdDoc.Bookmarks("GraphImage").Range.InlineShapes.AddPicture Filename:=GraphImage, LinkToFile:=False, SaveWithDocument:=True End If wrdDoc.SaveAs "c:\temp\test.doc" ' close the document Set wrdDoc = Nothing Set wrdApp = Nothing End With regards
Tags (comma-separated)
Save Edits
Cancel