{INCLUDEPICTURE} in doc needs saving first :-(

M

mog

I am having an annoying Issue with Word updating INCLUDEPICTURE
fields. I have a nested field setup, eg {INCLUDEPICTURE "{DOCPROPERTY
"headerA"} \*MERGEFORMAT} - ther custom DOCPROPERTY field is
populated by a piece of .NET code.

The issue is the following;

When I create a new document from the template containing the above
code, I can see that the code is part working as when I toggle to the
text view of the INCLUDEPICTURE code, the file name I would expect to
see as the source of the image is correct. The image itself however,
has not updated. If I move into the header field and select All and
then press F9, nothing changes. Nor if I do a print preview or what
ever. In order for the graphic to show, I must SAVE THE DOCUMENT, close
it, open it and then go in and press select all+ F9. this is obviously
a massive inconvenience, considering the document is created correctly
with the fields updated with the relavent values, why isnt the picture
actually showing until I save and reopen? I would like to find a
solution to this which doesnt involve writing VBA code in the Word
document itself, it would be massively preferable to achieve this from
the .NET code that drives the whole process.

Any ideas?
 
J

Jezebel

There's no obvious connection between saving a document and updating its
fields, other than the fields getting updated when you re-open. Have you
tried updating the field twice? (once to update the DocProperty field, then
the second time to refresh the IncludePicture)
 
C

Cindy M.

Hi Mog,
In order for the graphic to show, I must SAVE THE DOCUMENT, close
it, open it and then go in and press select all+ F9.
Could you give us an example of the path information you're putting
in the document property?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
M

mog

This is what I have in my VB.NET program; It sucessfully updates the
fields, as I have a test text DOCPROPERTY field which is always updated
correctly.



oCustomProps = d.CustomDocumentProperties()

For each prop in oCustomProps

if prop.Name ="headerA" Then prop.value = "THEIMAGE.jpg"

Next



Dim afield As Word.Field

For Each afield In
d.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.Fields()
On Error Resume Next
If afield.LinkFormat.AutoUpdate = False Then
afield.LinkFormat.Update()
Next afield

For Each afield In
d.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.Fields()
On Error Resume Next
If afield.LinkFormat.AutoUpdate = False Then
afield.LinkFormat.Update()
Next afield


For Each afield In
d.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.Fields()
On Error Resume Next
If afield.LinkFormat.AutoUpdate = False Then
afield.LinkFormat.Update()
Next afield

d.Activate()





In the Word Document (in the header) I have this code.


{INCLUDEPICTURE "{DOCPROPERTY "headerA"}" \* MERGEFORMAT}
{DOCPROPERTY "headerA"}

The {DOCPROPERTY "headerA"} line proves that the value is being fed
into the document OK.

Like I said, it works, in so much as all I have to do is *save the
document*, and then toggle field codes a few times, or press F9 whilst
selecting everything in the header, and the image is updated. But I
would really like to do this manual bit BEFORE the page is saved and
then loaded! Any ideas?
 
C

Cindy M.

Hi Mog,
Like I said, it works, in so much as all I have to do is *save the
document*, and then toggle field codes a few times, or press F9 whilst
selecting everything in the header, and the image is updated. But I
would really like to do this manual bit BEFORE the page is saved and
then loaded! Any ideas?
OK, so you're putting only a file name into the document property.

<<When I create a new document from the template containing the
above code, I can see that the code is part working as when I
toggle to the text view of the INCLUDEPICTURE code, the file name I
would expect to see as the source of the image is correct. The
image itself however, has not updated... In order for the graphic
to show, I must SAVE THE DOCUMENT, close it, open it and then go in
and press select all+ F9.>>

It's quite logical that the document can't show the graphic without
a full path if the document has never been saved. How should Word
know where to look for it? Try saving the document, first, then
insert the file path information and update the fields.

Or, try putting the entire path to the graphic into the doc
variable, update the fields, save the document, then change the
contents of the doc variable to leave just the name.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top