Office Word Programming >> Bookmark and replace picture

by digbydog » Wed, 16 May 2007 08:29:12 GMT

Hi,

I am using bookmarks in templates to be able to replace text returned from a
database which is all working fine. Also in the template is a picture and I
was hoping to do a similar thing using bookmarks but have been unable to
work it out.

I was using the bookmark to get the range where the picture is and then add
the new picture using ActiveDocument.Shapes.AddPicture() and then set the
size of the new picture of the current one and then delete the old one.

Issue is that the enclosed bookmark containing the picture doesn't seem to
include the picture itself as when the bookmark is deleted the picture
remains.

Has anyone tried to do something similar? Also there may be more than one
picture in the document so trying to use the shapes collection and
add/remove won't work unless I can somehow assign a name to each picture.

Hope that makes sense and if anyone has any ideas please let me know.

thanks
Simon




Similar Threads

1. How to replace a picture inserted at bookmark with another

2. Replaced picture does not inherit prior picture characteristics

On occasion I have noticed that I can open a Word document containing an 
in-line picture and paste another picture that is obviously of a different 
size on top of the existing picture and the new picture will be placed in the 
document while taking on the characteristics - size most notably - of the 
previously inserted picture.

On other occasions I note that this does not happen and each time I replace 
a picture the new picture must be resized and otherwise adjusted to fit in 
the document page.

I work with Visio and Word quite a bit and use the Visio "Copy Drawing" 
feature to grab an image of the drawing to insert into my Word documents. 
When the Word feature I describe above is active it makes this task soooo 
much easier.

So, is there a Word setting that controls this behavior?

3. replace picture with another picture (keeping formatting)

4. Insert pictures in word document - search and replace with a picture

Hi All,

I am trying to create a macro for Word 2003 that will loop through a 
document and insert a book cover picture from a file directory based on the 
a code in the document

At the moment we have a table with the following:
      Isbn
     Fmt
     Image
     Title
     Author
     Was
     Now

      07121654654

     Additup
     Book Title 1
     Mor
     26.95
     7.99

      0146543078

     Addkeki
     Book Title 2
     Padraic
        29.95
          7.99

      9780755464
     B
     BDUFIJO
     Book Title 3
     BISSETTI
     24.99
     7.99

      9780399564
     B
     CDUJOBO
     Book Title 4
     LEHM
     24.99
     7.99




I want to be able to run a macro that will, based on the code in the image 
column, go into c:\pictures\a or c:\pictures\b or whatever based on the 
first letter.
I would like to be able to also resize the graphic to a standard size  e.g. 
95 w x 120 h  (for example)

Any Ideas?

Thanks in advance

Steven Reid 


5. Replace text with bookmark in word document - CSharp/C#

6. INCLUDETEXT - replace bookmark name

I need to create a find/replace function that will allow me to replace the 
bookmark name in the "INCLUDE TEXT" field.  I've searched this site and found 
an example that I'm testing with.  As I debug this code, I see that "afield" 
has the data that I need to change, all I really want to do is search for 
AUGUST in the field and replace with SEPTEMBER, since I can't seem to get 
that to work for me, I decided to search on the complete fieldcode, although 
I'm getting a compiler error on my "afield.code like" statement. 
Can anyone see what I'm doing wrong with this?? 

Dim afield As field
With ActiveDocument
    For Each afield In .Fields
        If afield.code = "INCLUDETEXT "\\\\NETWORK 
SERVER\\dirNAME\\DIRECTORY2\\msword.doc " AUGUST" Then
            afield.Select
            Selection.Range.Text = "INCLUDETEXT "\\\\NETWORK 
SERVER\\dirNAME\\DIRECTORY2\\msword.doc" SEPTEMBER"
        End If
    Next afield
End With

7. Symbol from database via bookmark being replaced - Word Document management

8. Find & Replace Bookmarks

Hello,

I'm looking to find & replace bookmarks throughout a document.  Is there a 
code for bookmarks?

I want to locate all bookmarks and replace with *B*.

Thanks.