首页 \ 问答 \ Excel OpenText方法(Excel OpenText method)

Excel OpenText方法(Excel OpenText method)

我不断收到0x800A03EC的模糊错误代码

我一直在寻找相当多的东西,看看能否找到错误的具体原因,但不幸的是,代码似乎涵盖了大量可能的错误。 我会复制和粘贴似乎给我带来问题的代码,希望有人能够向我提供一些关于如何解决问题的反馈。 我正在使用这个kb21686文章中遇到的称为AutoWrap的方法。

我会在这里添加该方法:

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->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &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<cArgs; i++) {
        pArgs[i] = va_arg(marker, VARIANT);
    }

    // Build DISPPARAMS
    dp.cArgs = cArgs;
    dp.rgvarg = pArgs;

    // Handle special-case for property-puts!
    if(autoType & DISPATCH_PROPERTYPUT) {
        dp.cNamedArgs = 1;
        dp.rgdispidNamedArgs = &dispidNamed;
    }

    // Make the call!
    hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &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;
}

一切正常,直到我打电话:

AutoWrap(DISPATCH_PROPERTYGET, &result, pXlBooks, L"OpenText",18,param1,vtMissing,vtMissing,paramOpt,paramOpt,
                vtMissing,vtMissing,vtMissing,paramTrue,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing
                ,vtMissing,vtMissing);

传递给函数的参数被初始化为:

       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");

如果我取消注释掉的param1并打开Open并调用它,那么param1的所有版本都可以很好地工作。 不幸的是,当在OpenText方法上调用Invoke时,我得到0x800A03EC错误代码。 我搜索时发现的90%是使用C#中的互操作来执行自动化,而另外10%是在VB中做同样的事情,虽然C#示例有帮助,但它们无助于解释使用C ++时传递的参数。 我觉得这对参数来说都是一个问题,但我很难弄清楚它们的问题究竟是什么。

预先感谢您提供的任何帮助,如果我需要发布更多代码,请通知我。


I keep getting the ambiguous error code of 0x800A03EC. 

 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 kb21686  article.

I'll add that method here:

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->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &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<cArgs; i++) {
        pArgs[i] = va_arg(marker, VARIANT);
    }

    // Build DISPPARAMS
    dp.cArgs = cArgs;
    dp.rgvarg = pArgs;

    // Handle special-case for property-puts!
    if(autoType & DISPATCH_PROPERTYPUT) {
        dp.cNamedArgs = 1;
        dp.rgdispidNamedArgs = &dispidNamed;
    }

    // Make the call!
    hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &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;
}

Everything works fine up until I make this call:

AutoWrap(DISPATCH_PROPERTYGET, &result, pXlBooks, L"OpenText",18,param1,vtMissing,vtMissing,paramOpt,paramOpt,
                vtMissing,vtMissing,vtMissing,paramTrue,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing
                ,vtMissing,vtMissing);

The parameters passed to the function are initialized as:

       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");

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 0x800A03EC error code. 90% of what I find when searching is 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.

Thanks in advance for any help you can offer and pelase let me know if I need to post more code.


原文:https://stackoverflow.com/questions/1492513
更新时间:2023-12-04 16:12

最满意答案

看一下filter_var来验证语法:

if (filter_var($email[0], FILTER_VALIDATE_EMAIL)) {
    // email address is considered valid

请注意,有一些方法可以连接到收件人SMTP服务器并询问电子邮件是否确实存在(例如,请参阅https://code.google.com/p/php-smtp-email-validation/ )但是许多电子邮件服务器赢了“由于滥用垃圾邮件而不再尊重这些查询。


Take a look at filter_var to validate the syntax:

if (filter_var($email[0], FILTER_VALIDATE_EMAIL)) {
    // email address is considered valid

Note that there are ways to connect to the recipients SMTP server and ask if the email actually exists (see https://code.google.com/p/php-smtp-email-validation/ for example) however many email servers won't honor these queries anymore, due to spammer abuse.

相关问答

更多
  • 这不是你早期问题的重复吗? 我看不出有太多变化。 您没有正确使用代理(您不能在套接字内部套接字),但PHPMailer没有任何特定的代理支持。 如果它将在任何地方,我会在SMTPOptions中设置属性,但据我所知PHP只在HTTP流中提供代理支持,因此您可能是SOL。 运行本地邮件服务器来传递而不是代理可能更容易。 I finally found the solution using socat, Kindly follow these steps : First of all, you'll need ...
  • 这个问题的措辞很含糊。 看起来您需要做的是将标记为转移('T')的任何房间移动到空房间('V')并将其标记为已占用(假设为“O”),并将转移的房间标记为空置。 所以你所需要做的就是在最后一个if块中采取适当的步骤。 *arr[x] = 'O'; // set vacant room as occupied. hospitalFloors[i][j] = 'V'; // set transfer room as vacant arr[x] = &hospitalFlo ...
  • 是的,但你需要小心。 使用用户提交的地址作为发件人地址是一个非常糟糕的主意,也就是说不要这样做: $mail->setFrom($_POST['email']); 这是伪造的,并且会导致您的邮件无法通过SPF检查,因此邮件将不会被发送,或者最终会收到垃圾邮件文件夹。 正确的做法是,使用固定的发件人地址,但添加回复地址,以便回复提交给提交者: $mail->setFrom('me@example.com'); $mail->addReplyTo($_POST['email']); 如果你想发送到用户提交的 ...
  • 这是使用GNU awk的一种方法: tcpdump -i eth1 -n -c 5 ip | awk '{ print gensub(/(.*)\..*/,"\\1","g",$3), $4, gensub(/(.*)\..*/,"\\1","g",$5) }' Here's one way using GNU awk: tcpdump -i eth1 -n -c 5 ip | awk '{ print gensub(/(.*)\..*/,"\\1","g",$3), $4, gensub(/(.*)\. ...
  • 看一下filter_var来验证语法: if (filter_var($email[0], FILTER_VALIDATE_EMAIL)) { // email address is considered valid 请注意,有一些方法可以连接到收件人SMTP服务器并询问电子邮件是否确实存在(例如,请参阅https://code.google.com/p/php-smtp-email-validation/ )但是许多电子邮件服务器赢了“由于滥用垃圾邮件而不再尊重这些查询。 Take a look ...
  • 尝试去: myaccount.google.com - > “连接的应用程序和网站” ,并将“允许不太安全的应用程序”设置为“开启” 。 替代方法:尝试更改SMTP端口为:465(也是Gmail)。 Make sure you check google's usage limits! PHPMailer will not tell you particulars it will just give you the Could not authenticate error but the reason why ...
  • 没有显示的代码可以准确而积极地确定您的问题。 但是你的$row强烈暗示你已经过了一段while($row=$stmt->fetch()) ,对吧? 我们在您显示的代码中看不到任何类似的内容。 我想我有99%的机会对此表示正确。 您的修复是在PHPMailer部分之前“提取”您的数据库数据 。 获取所有变量(发件人,发件人,发件人名称和一系列地址......还有一系列BCC?)。 在进入PHPMailer部分之前完成while fetch循环 ,该部分不应包含在循环中。 那么 ,你可以继续你的电子邮件建设。 ...
  • 您应首先删除单引号,然后逐行获取值并使用trim()删除空格然后使用str_replace()删除'\ n','\ t','\ r' You should remove single quotes first, then get value line by line and remove whitespaces using trim() then remove '\n', '\t', '\r' using str_replace()
  • 所以,虽然我认为你在这里使用委托来确保代码发生一次,但它中包含的代码会多次发生。 澄清一下:每次单击div中包含的输入时,它都会执行委托函数的主体。 结果? 您附加了一个keyup处理程序。 点击2? 您附加了一个keyup处理程序。 点击3? 一样。 函数体内部的内容是绑定到keyup事件,将来不会破坏该keyup事件,因此会多次执行该事件。 你最好这样做: http://jsfiddle.net/notsoluckycharm/NYdVA/ $("div").delegate(".vid_form"," ...
  • 以下将生成一个list s list ,其中包含小于给定数字的3和5的所有倍数。 L = [10,20] L1 = [] for i in L: L2 = [] # initialize a new list for j in range(i): if not (j%3 and j%5): # use falsy values and DeMorgan's Law L2.append(j) # append to this list if L2 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)