Word automation: document properties

V

vino

Hi all,
I hope this is the right place for such question:

I have a trouble working with MS Word from C++ (MSVC++ 6.0).
There is a simple task:
1. Open a document,
2. read and change some custom document properties,
3. print the document.

The way that seemed simple to me was use class wizard - automation - new
class - from type library...
This generated some nice wrapper classes which are usable but with no
documentation available at all. (please let me know if I am wrong).

However, someting works but someting doesn't:

_Application objWord;

if (!objWord.CreateDispatch("Word.application", &rError)) {...}
objWord.SetVisible(FALSE);

Documents docs(objWord.GetDocuments());
_Document testDoc;

testDoc.AttachDispatch(docs.Open(...));

// until here it works

LPDISPATCH lpDisp;
long lCount;

lpDisp = testDoc.GetBuiltInDocumentProperties();

CustomProperties rProp(lpDisp);
lCount = rProp.GetCount();
// here the exception - "member not found" is raised

what could be wrong?

thanks,
best regards Vit
 
C

Cindy M -WordMVP-

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

I don't know about C++ and such, but...

The DocumentProperty and DocumentProperties object/collection are actually
part of the OFFICE object library. BuiltInDocumentProperty, -ies and
CustomDocumentProperty, -ies are how you can get to them through the Word
VBA interface. But that may not work for C++?
I have a trouble working with MS Word from C++ (MSVC++ 6.0).
There is a simple task:
1. Open a document,
2. read and change some custom document properties,
3. print the document.

The way that seemed simple to me was use class wizard - automation - new
class - from type library...
This generated some nice wrapper classes which are usable but with no
documentation available at all. (please let me know if I am wrong).

However, someting works but someting doesn't:

_Application objWord;

if (!objWord.CreateDispatch("Word.application", &rError)) {...}
objWord.SetVisible(FALSE);

Documents docs(objWord.GetDocuments());
_Document testDoc;

testDoc.AttachDispatch(docs.Open(...));

// until here it works

LPDISPATCH lpDisp;
long lCount;

lpDisp = testDoc.GetBuiltInDocumentProperties();

CustomProperties rProp(lpDisp);
lCount = rProp.GetCount();
// here the exception - "member not found" is raised

what could be wrong?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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