Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

{INCLUDEPICTURE} in doc needs saving first :-(

8 views
Skip to first unread message

mog

unread,
Sep 27, 2006, 5:34:44 AM9/27/06
to
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?

Jezebel

unread,
Sep 27, 2006, 6:21:15 AM9/27/06
to
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)


"mog" <mog...@gmail.com> wrote in message
news:1159349684.3...@b28g2000cwb.googlegroups.com...

Cindy M.

unread,
Sep 28, 2006, 5:55:38 AM9/28/06
to
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 :-)

mog

unread,
Oct 2, 2006, 5:33:52 AM10/2/06
to
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?

Cindy M.

unread,
Oct 3, 2006, 8:12:09 AM10/3/06
to
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.

0 new messages