WordBasic.CountWindows() behaves differently in Word2003 from Word

U

Uday

Hi ,

I have an ActiveX control which creates a word docuemnt by linking to
the specified word. This is done using OLE stuff like monikers & binding to
the object. The scaled down code looks like this,

LPMONIKER pmk;
LPBC pbc;
LPDISPATCH pppvResult = NULL;

CString docName("..\\xyz.doc");

hr = CreateBindCtx(0, &pbc);
if (SUCCEEDED(hr)) {
hr = MkParseDisplayName(pbc, T2OLE(docName), &cEaten, pMon);
pbc->Release();
}

ASSERT(pMon!= NULL);
hr = pMon->BindToObject(pbc, NULL, IID_IDispatch, pppvResult);
pbc->Release();
pmk->Release();

At BindToObject the word object is created(I see that at this point
winword.exe process appears in TaskManager process window). Also a temp file
$xyz.doc is created indicating the file is opened. At this point the window
is not active yet or visible. pppvResult is used to get the WordObject and
CountWindows using IDispatch calls GetIDsOfNames, GetProperty.

I comapred each of the calls in Word 2000 & Word 2003. Except the call
to CountWindows() everything is fine. With Word 2003 it returns 1 but with
Word 2000 it returns 0. I donot understand why is the difference. I donot get
any error message. The Invoke method call returns success. As per the
CountWindows
description in WordBasic hlp file, it gives the count of windows in the
windows menu.

Can any one you suggest a solution (other than shifting to VBA code) or a
better place where I can post this. Thank you in advance.

--uday.
 

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