R
robert
Hi all,
I wonder if someone can shed light on this problem which I have somehow
solved/circumvented but without exactly understanding why or how. I'm
programming an add-in for Word 2007 in C# using VS2005 + VSTO. It's the
first project I've done in Word so I'm still a Word programming novice.
The task is to populate a table with images from disk as well as
specific text that can be read from each image file with some other
code. Later on I want to read a saved word document and retrive images
and text strings from that document into member data of the Add-In.
This is particular easy with Word 2007 docs as they are zip files and
InlineShape images are stored in \word\media subfolder within the zip
files. To that end the Add-In is bookmarking each InlineShape with the
image file name and is using an unzip routine whenever I reopen the
word file.
Without going into too much details suffice it to say that the code for
the Add-In amounts to messing about with the documents InlineShapes
collection and the ContentControls collection. I thought I could keep
my code simple by creating private instances of an InlineShapes
collection and a ContentControls collection within my C# add-in which I
would then create in the relevant table cells and populate with my
images and text.
However, I got errors amounting to literally every other instance of
the supposedly populated InlineShape members of my collection being a
null value later on in the executing code. This applied as well to the
ContentControls collection I created.
Eventually I rewrote my code and am now exclusively using the
InlineShapes and ContentControls collection inherent in the word
document. This appears to work perfectly. So I suspect that creating
any of the collection objects already present in a word document is
asking for trouble, right?
It would be great if anyone could clarify what the flippin heck is
going on with those InlineShapes and ContentControls collections as it
has really been doing my head in (anyone got an aspirin?)
Rob Oeffner
I wonder if someone can shed light on this problem which I have somehow
solved/circumvented but without exactly understanding why or how. I'm
programming an add-in for Word 2007 in C# using VS2005 + VSTO. It's the
first project I've done in Word so I'm still a Word programming novice.
The task is to populate a table with images from disk as well as
specific text that can be read from each image file with some other
code. Later on I want to read a saved word document and retrive images
and text strings from that document into member data of the Add-In.
This is particular easy with Word 2007 docs as they are zip files and
InlineShape images are stored in \word\media subfolder within the zip
files. To that end the Add-In is bookmarking each InlineShape with the
image file name and is using an unzip routine whenever I reopen the
word file.
Without going into too much details suffice it to say that the code for
the Add-In amounts to messing about with the documents InlineShapes
collection and the ContentControls collection. I thought I could keep
my code simple by creating private instances of an InlineShapes
collection and a ContentControls collection within my C# add-in which I
would then create in the relevant table cells and populate with my
images and text.
However, I got errors amounting to literally every other instance of
the supposedly populated InlineShape members of my collection being a
null value later on in the executing code. This applied as well to the
ContentControls collection I created.
Eventually I rewrote my code and am now exclusively using the
InlineShapes and ContentControls collection inherent in the word
document. This appears to work perfectly. So I suspect that creating
any of the collection objects already present in a word document is
asking for trouble, right?
It would be great if anyone could clarify what the flippin heck is
going on with those InlineShapes and ContentControls collections as it
has really been doing my head in (anyone got an aspirin?)
Rob Oeffner