Solved

Insert Image into Word Document Bookmark

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

705 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

15 Experts available now in Live!

Get 1:1 Help Now