Edve

Hi,

I have a question about the usage of InlineSape.LinkFormat.AutoUpdate!

In our application we add inlineshapes to a document which we later on want to update from the hard-disk with a new generated image. We explicitly tell word to save the pictures with the document (saveWithDocument), and also say it must link to the file. The problem is that when we re-open the document, (and the original images are not on disk anymore) then the image is not displayed in the document. The adding of images is as followed:

Code Snippet

object missing = System.Reflection.Missing.Value;

object linkPictureToFile = true;

object saveWithDocument = true;

InlineShape shape = range.InlineShapes.AddPicture(imagePath, ref linkPictureToFile, ref saveWithDocument, ref rangeUse);

And then later on when we update the image, after creating the new image, we want to update the picture and do it like this:

Code Snippet

shape.LinkFormat.SourceFullName = imagePath;//the fullName of the generate picuture

shape.LinkFormat.Locked = true;//which should prevent the image from updating automatically !

shape.LinkFormat.Update();

shape.Reset();

shape.LinkFormat.AutoUpdate = false;//This generates an interop runtime comexception.

Can anyone explain how this mechanism works / what we are doin wrong Any suggestions would be welcome!

Regards

Edve



Re: Visual Studio Tools for Office usage of InlineSape.LinkFormat.AutoUpdate

Cindy Meister

Are you using VSTO

Which version of Word are you working with






Re: Visual Studio Tools for Office usage of InlineSape.LinkFormat.AutoUpdate

Edve

I am using vsto 2005 second edition, and the version of word is 2003.



Re: Visual Studio Tools for Office usage of InlineSape.LinkFormat.AutoUpdate

Cindy Meister

I'm surprised you say that the images are no longer visible in the file when they're missing on disk. For the last couple of versions or so, if "SaveInDocument" is true, the image information is saved in the document and should still be visible if the link cannot update. I've never seen it do otherwise, but Word can be unpredictable...

According to my understanding of how InlineShape updates function, AutoUpdate would indeed be invalid. These links are maintained by IncludePicture fields in the document, and this field does not support the \a switch. (You can toggle on the field code by pressing Alt+F9.)

Generally, I manage these kinds of pictures directly over the field code, rather than trying to work with the LinkFormat. In very early versions of Word the LinkFormat object had a nasty tendency to cause Word to crash, so I just got in the habit of avoiding it. It's much more stable these days, but manipulating the actual field code is always more... predictable - and you can check exactly what your code has changed. When you set a field's Locked property to True, in order to allow it to update again you must set this property to False. And then force the field to update using the Update method.