Note that there are some explanatory texts on larger screens.

plurals
  1. POExcel OpenText method
    text
    copied!<p>I keep getting the ambiguous error code of <strong>0x800A03EC.&nbsp;</strong></p></p> <p>&nbsp;I've been searching quite a bit to see if I could find a specific reason for the error but unfortunately that code seems to cover a multitude of possible errors. I will copy and paste the code that seems to be giving me problems and hopefully someone will be able to provide me with some feedback on how I might solve the problem. I am using a method called AutoWrap that I came across in this <a href="http://support.microsoft.com/kb/216686" rel="nofollow noreferrer">kb21686 </a>&nbsp;article.<br /><br />I'll add that method here:<br /></p> <pre>HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...) { // Begin variable-argument list... va_list marker; va_start(marker, cArgs); if(!pDisp) { //MessageBox(NULL, "NULL IDispatch passed to AutoWrap()", "Error", 0x10010); MessageBox(NULL,_T("IDispatch error"),_T("LError"),MB_OK | MB_ICONEXCLAMATION); _exit(0); } // Variables used... DISPPARAMS dp = { NULL, NULL, 0, 0 }; DISPID dispidNamed = DISPID_PROPERTYPUT; DISPID dispID; HRESULT hr; char buf[200]; char szName[200]; // Convert down to ANSI WideCharToMultiByte(CP_ACP, 0, ptName, -1, szName, 256, NULL, NULL); // Get DISPID for name passed... hr = pDisp-&gt;GetIDsOfNames(IID_NULL, &amp;ptName, 1, LOCALE_USER_DEFAULT, &amp;dispID); if(FAILED(hr)) { sprintf_s(buf, "IDispatch::GetIDsOfNames(\"%s\") failed w/err 0x%08lx", szName, hr); MessageBox(NULL, CString(buf), _T("AutoWrap()"), MB_OK | MB_ICONEXCLAMATION); _exit(0); return hr; } // Allocate memory for arguments... VARIANT *pArgs = new VARIANT[cArgs+1]; // Extract arguments... for(int i=0; i&lt;cArgs; i++) { pArgs[i] = va_arg(marker, VARIANT); } // Build DISPPARAMS dp.cArgs = cArgs; dp.rgvarg = pArgs; // Handle special-case for property-puts! if(autoType &amp; DISPATCH_PROPERTYPUT) { dp.cNamedArgs = 1; dp.rgdispidNamedArgs = &amp;dispidNamed; } // Make the call! hr = pDisp-&gt;Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &amp;dp, pvResult, NULL, NULL); if(FAILED(hr)) { sprintf_s(buf, "IDispatch::Invoke(\"%s\"=%08lx) failed w/err 0x%08lx", szName, dispID, hr); MessageBox(NULL, CString(buf), _T("AutoWrap()"), MB_OK | MB_ICONEXCLAMATION); _exit(0); return hr; } // End variable-argument section... va_end(marker); delete [] pArgs; return hr; }</pre> <p>Everything works fine up until I make this call:<br /></p> <pre>AutoWrap(DISPATCH_PROPERTYGET, &amp;result, pXlBooks, L"OpenText",18,param1,vtMissing,vtMissing,paramOpt,paramOpt, vtMissing,vtMissing,vtMissing,paramTrue,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing ,vtMissing,vtMissing);</pre> <p>The parameters passed to the function are initialized as:</p> <pre> VARIANT param1,paramOpt,paramFalse,paramTrue; param1.vt = VT_BSTR; paramOpt.vt = VT_I2; paramOpt.iVal = 1; paramFalse.vt = VT_BOOL; paramFalse.boolVal = 0; paramTrue.vt = VT_BOOL; paramTrue.boolVal = 1; //param1.bstrVal = ::SysAllocString(L"C:\\Documents and Settings\\donaldc\\My Documents\\DepositSlip.xls"); param1.bstrVal = ::SysAllocString(L"C:\\logs\\TestOut.txt");</pre> <p>If I uncomment the commented out param1 and make a call to Open and pass it that version of param1 everything works wonderfully. Unfortunately when Invoke is called on the OpenText method I get the&nbsp;0x800A03EC error code. 90%&nbsp;of what I find when searching is&nbsp;performing automation using interop in C# and the other 10% is doing the same thing in VB and while the C# examples are helpful they don't help to explain the parameters being passed when using C++ very well. I feel like it's all a problem with parameters but I'm having difficulty in figuring out exactly what the problem with them is.</p> <p>Thanks in advance for any help you can offer and pelase let me know if I need to post more code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload