How to access CustomXMLParts of Subdocuments

  • Thread starter Andrew W. Jones
  • Start date
A

Andrew W. Jones

I have a Word master document that has subdocuments. I have an Application
level addin that needs to access the customxmlparts of the subdocuments. Is
this possible?

I tried the following:

foreach (Word.Subdocument sub in document.Subdocuments)
{
Word.Document subDoc = sub.Open(); // Fails with HRESULT E_FAIL

// Access subDoc's customxmlparts here

subDoc.Close(ref missing, ref missing, ref missing);
}

but it fails when opening the subdocument.

I haven't seen any portion of the Word object model that would allow direct
access to subdocument customxmlparts either.

Cheers
 
C

Cindy M.

Hi =?Utf-8?B?QW5kcmV3IFcuIEpvbmVz?=,

You should always put Office automation code in a Try...Catch block. That will
give you maximum information about errors. Try that and see if you get an error
message with more information?

FWIW, when I try your approach it works fine. I tested with docx file formats
for both Master and Sub-document. Could there be a problem with the file format
of your sub-document?

What happens if you try to open the sub-document as an end-user?
I have a Word master document that has subdocuments. I have an Application
level addin that needs to access the customxmlparts of the subdocuments. Is
this possible?

I tried the following:

foreach (Word.Subdocument sub in document.Subdocuments)
{
Word.Document subDoc = sub.Open(); // Fails with HRESULT E_FAIL

// Access subDoc's customxmlparts here

subDoc.Close(ref missing, ref missing, ref missing);
}

but it fails when opening the subdocument.

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