Word, Excel automation

J

JB

I am developing a COM framer component and am having trouble with Excel
automation. I can load and display a sheet loaded from a storage but cannot
get 'Find' to work.

For both Word and Excel, the code begins with
-- open my app file coNtaining storage
-- get clsid from CLSIDFromProgID("Word.Document" or "Excel.Sheet"
-- CoCreateInstance(clsid, .. LOCAL_SERVER, IID_iDispatch, &pDoc)
-- pStg from pDoc-> QI(IPersistStorage)
-- Load()

With Word
pContent from AutoWrap( ... PROPERTYGET, .. L"Content".. )
pFind from AutoWrap (.. PROPERTYGET ... L"Find" ..)
.. set Find properties, eg. forward, Matchcase, etc
then
Variant x;
x.vt = VT_BSTR;
x.bstrVal = L"cat"
Autowrap(. . METHOD, ..L"Execute", x )

This all works (for Word).

When I try the same sort of thing for Excel I can't seem to work out the
right set of calls. After the same code for loading from the storage
I tried
pCells from AutoWrap( .. PROPERTYGET. pDoc, L"Cells" )
but get pCells = Null
Then tried pDoc Activate then Cells, still returns pCells = Null
Then tried pApp from pDoc, then pSheets then pSheet then Activate and always
somewhere along the line, a null ptr is returned.
From pCells, then I would use
Variant x;
x.vt = VT_BSTR;
x.bstrVal = L"cat"
AutoWrap(... METHOD , L"Find", x)
but so far I haven't been able to get that far.
 

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