Solved

Insert Image into Word Document Bookmark

Posted on 2002-06-27
2
336 Views
Last Modified: 2010-05-18
I have a template set up in Microsoft Word.  There is a bookmark called IMAGE, and that is where I want to insert an image if one is selected from my VB program.  In my VB program I am using a common dialog box to allow people to choose an image and then I have a picture box called picture1 that displays the image, so that a person can see if he/she likes the image before creating the word document with the image in it... the only problem is that I am having trouble inserting the image.  I have tried copying it to the clipboard and pasting it in the bookmark, but that didn't seem to work...here is what I have so far:

    ElseIf UCase$(lsBookmarkName) = "IMAGE" Then
        Clipboard.Clear   ' Clear Clipboard.
        Clipboard.SetData LoadPicture(Me.CommonDialog2.FileName)
       loWord.Bookmarks("IMAGE").Select
       ActiveWindow.ActivePane.Selection.Paste

For some reason it puts whatever is in the next bookmark in the place where I have the IMAGE bookmark...
0
Comment
Question by:zippy221
2 Comments
 
LVL 3

Accepted Solution

by:
schworak earned 50 total points
ID: 7115378
Because the image you are trying to insert is a file it would be much easier to have word do the insert instead of copying and pasting. Try this....

Selection.GoTo What:=wdGoToBookmark, Name:="IMAGE"
Selection.InlineShapes.AddPicture FileName:= _
        "\\Cbs_imd\DATA\users\schworgj\temp\Pictures\Iceberg.bmp", _
        LinkToFile:=False, SaveWithDocument:=True
0
 

Author Comment

by:zippy221
ID: 7121821
Works like a charm!  Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now