H
Horatiu Gilea
Apparently, I found the cause for the behaviour that was
the subject of my yesterday post.
After applying Excel 2000 Security Patch 830349, using
Range.Find object through automation, using ATL (i.e. not
through IDispatch) gives "The value of ESP was not
properly saved across a function call" !
There should be no link between an Excel patch, documented
as chganging only Excel.exe, and Word, but my tests are
clear: uninstall Office, then install it, install SP3 and
run the below test is OK. Install 830349 and the error
occurs.
Apparently, the VMT is messed up for the entries that
follow IDispatch methods...
Proof code:
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Word.Application", &clsid);
hr = m_pWord.CreateInstance(clsid);
m_pWord->Visible = VARIANT_TRUE;
VARIANT varFileName;
varFileName.vt = VT_BSTR;
// put here a valid document
varFileName.bstrVal = SysAllocString(L"C:\\Test.doc");
varOpt.vt = VT_ERROR;
varOpt.scode = DISP_E_PARAMNOTFOUND;
VARIANT varFalse;
varFalse.vt = VT_BOOL;
varFalse.boolVal = VARIANT_FALSE;
AfxMessageBox(_T("Before Open"));
m_pDoc = m_pWord->Documents->Open(&varFileName, &varFalse,
&varFalse, &varFalse, &varOpt, &varOpt, &varOpt, &varOpt,
&varOpt, &varOpt);
AfxMessageBox(_T("After Open"));
::VariantClear(&varFileName);
Word::RangePtr m_pRange = m_pDoc->Range(&varOpt, &varOpt);
Word::FindPtr m_pFind = m_pRange->GetFind();
// this call fails, as well as any other Find object method
_bstr_t bstrText = m_pFind->GetText();
AfxMessageBox(bstrText);
Any ideas? Am I the only one that has this behaviour?
OS: Windows2000 SP4
Office 2003 SP3
Thanks
Horatiu
the subject of my yesterday post.
After applying Excel 2000 Security Patch 830349, using
Range.Find object through automation, using ATL (i.e. not
through IDispatch) gives "The value of ESP was not
properly saved across a function call" !
There should be no link between an Excel patch, documented
as chganging only Excel.exe, and Word, but my tests are
clear: uninstall Office, then install it, install SP3 and
run the below test is OK. Install 830349 and the error
occurs.
Apparently, the VMT is messed up for the entries that
follow IDispatch methods...
Proof code:
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Word.Application", &clsid);
hr = m_pWord.CreateInstance(clsid);
m_pWord->Visible = VARIANT_TRUE;
VARIANT varFileName;
varFileName.vt = VT_BSTR;
// put here a valid document
varFileName.bstrVal = SysAllocString(L"C:\\Test.doc");
varOpt.vt = VT_ERROR;
varOpt.scode = DISP_E_PARAMNOTFOUND;
VARIANT varFalse;
varFalse.vt = VT_BOOL;
varFalse.boolVal = VARIANT_FALSE;
AfxMessageBox(_T("Before Open"));
m_pDoc = m_pWord->Documents->Open(&varFileName, &varFalse,
&varFalse, &varFalse, &varOpt, &varOpt, &varOpt, &varOpt,
&varOpt, &varOpt);
AfxMessageBox(_T("After Open"));
::VariantClear(&varFileName);
Word::RangePtr m_pRange = m_pDoc->Range(&varOpt, &varOpt);
Word::FindPtr m_pFind = m_pRange->GetFind();
// this call fails, as well as any other Find object method
_bstr_t bstrText = m_pFind->GetText();
AfxMessageBox(bstrText);
Any ideas? Am I the only one that has this behaviour?
OS: Windows2000 SP4
Office 2003 SP3
Thanks
Horatiu