W
winslars
I am currently making our OCX components Office-compatible and I have
run into a small problem that I haven't found a good solution for yet.
We have two control types: one represents the document and the other
represents
individual fields within that document. We want the document control to find
its
associated fields (or vice versa). Initially we developed this with IE as
container but
now we extend it to general OLE containers and the problem we have run into
is that Word does not seem to support IOLEContainer::EnumObjects. The code
that runs fine in Excel and PowerPoint and allows us to enumerate over the
embedded objects returns 0 (zero) objects in Word.
I have tried to find documentation about this on the Internet, but the info
is dated and indicates that Excel should have the same behavior and that is
definitely wrong.
There are suggestions about using the Word automation model, but I would
like to avoid that if I can and use general interfaces to accomplish the task.
Here is a snippet of my code that works in IE/Excel/PowerPoint but not in
Word:
("TOLEIP" is a smart pointer class, "ioc" is the IOleContainer pointer in my
control,
"_DQlix" is the dispatch interface to my satelite object)
TOLEIP<IEnumUnknown> pEnumerator;
// Get an enumerator for the embedded objects
HRESULT hr = ioc->EnumObjects (OLECONTF_EMBEDDINGS, &pEnumerator);
_ASSERTE (SUCCEEDED (hr));
if (FAILED (hr)) return;
TOLEIP<IUnknown> pUnk;
ULONG uFetched = 0;
for (UINT i = 0; pEnumerator->Next (1, &pUnk, &uFetched) == S_OK; i ++) {
// Try to convert IUnknown pointer into wanted interface
TOLEIP<IDispatch> pDQlix;
hr = pUnk->QueryInterface (__uuidof (_DQlix), (void**) &pDQlix);
pUnk = NULL;
if (pDQlix) {
// We have a match, use the interface
...
}
}
I am working at the low-level generic IOleContainer / IOleObject level.
I find it strange that Word does not supply the same kind of support that
Excel does, but everything seems to indicate that that is the case.
Any suggestions?
run into a small problem that I haven't found a good solution for yet.
We have two control types: one represents the document and the other
represents
individual fields within that document. We want the document control to find
its
associated fields (or vice versa). Initially we developed this with IE as
container but
now we extend it to general OLE containers and the problem we have run into
is that Word does not seem to support IOLEContainer::EnumObjects. The code
that runs fine in Excel and PowerPoint and allows us to enumerate over the
embedded objects returns 0 (zero) objects in Word.
I have tried to find documentation about this on the Internet, but the info
is dated and indicates that Excel should have the same behavior and that is
definitely wrong.
There are suggestions about using the Word automation model, but I would
like to avoid that if I can and use general interfaces to accomplish the task.
Here is a snippet of my code that works in IE/Excel/PowerPoint but not in
Word:
("TOLEIP" is a smart pointer class, "ioc" is the IOleContainer pointer in my
control,
"_DQlix" is the dispatch interface to my satelite object)
TOLEIP<IEnumUnknown> pEnumerator;
// Get an enumerator for the embedded objects
HRESULT hr = ioc->EnumObjects (OLECONTF_EMBEDDINGS, &pEnumerator);
_ASSERTE (SUCCEEDED (hr));
if (FAILED (hr)) return;
TOLEIP<IUnknown> pUnk;
ULONG uFetched = 0;
for (UINT i = 0; pEnumerator->Next (1, &pUnk, &uFetched) == S_OK; i ++) {
// Try to convert IUnknown pointer into wanted interface
TOLEIP<IDispatch> pDQlix;
hr = pUnk->QueryInterface (__uuidof (_DQlix), (void**) &pDQlix);
pUnk = NULL;
if (pDQlix) {
// We have a match, use the interface
...
}
}
I am working at the low-level generic IOleContainer / IOleObject level.
I find it strange that Word does not supply the same kind of support that
Excel does, but everything seems to indicate that that is the case.
Any suggestions?