Solved

Insert Image into Word Document Bookmark

Posted on 2002-06-27
2
339 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 59
MS Access - Capture pressed key onclick 4 41
How to debug this code 7 64
Copy a row 12 63
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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