word Find->Execute 0x800706F7
来源:互联网 发布:spss数据分析实验报告 编辑:程序博客网 时间:2024/05/21 05:20
环境:xp sp3,vs2003,word2007
问题:有的电脑在执行vba里面替换的时候会报错
VARIANT_BOOL bExec = pSel->Find->Execute(
&FindText, &MatchCase, &MatchWholeWord, &MatchWildcards, &MatchSoundsLike,
&MatchAllWordForms, &Forward, &Wrap, &Format, &FindText,&vtMissing);
原因:
当您所使用的进程外客户端应用程序使用早期绑定来使 Word 97 或更高版本自动运行时,该应用程序可能会由于存在访问冲突而崩溃,或者出现以下错误消息之一:
从 Microsoft Visual Basic 中:
Run-time error '-2147023113 (800706f7)':
The method '~' of object '~' failed
Run-time error '-2147023113 (800706f7)':
Method 'Execute' of object 'Find' failed
Run-time error 430:
Class does not support automation or does not support expected interface.
从 Microsoft Visual C++ 中:
HRESULT = 0x800706F7
RPC_X_BAD_STUB_DATA - The stub received bad data.
注意:在调试版本中,将会从“声明”对话框中收到堆栈损坏警告,并且 EAX 的值与上面列出的值相同。在发行版本中,堆栈损坏将可能在此后不久使该应用程序崩溃,但 HRESULT 值可能与上面的值类似。
该问题会在某些计算机上持续发生,但在另一些计算机上却可能永远不会发生。安装新的应用程序或 Microsoft Excel Service Pack 可能导致先前正常工作的计算机遇到该问题。
要解决此问题,请执行下列操作之一:
修改您的代码,在上面列出的任何 Word 接口上调用方法或属性时都使用晚期绑定。
- 或 -
在发生该问题的系统上重新注册 Word 类型库。
建议您使用晚期绑定解决方案。因为两种类型库均描述了实现 IDispatch 接口的接口,所以对任何 IDispatch 方法的调用都将有效,而与最后在系统上注册哪个类型库无关。这是确保您的代码不会在您未管理的系统上遇到此错误的唯一方法。
解决:
方法1:
// 执行含有N个参数的方法 BOOL CDjcxView::InvokeN(IDispatch *pDisp, LPCOLESTR lpszName, VARIANT *varParams, int nParams) { DISPID dispid; VARIANT varRet = {0}; HRESULT hr = pDisp->GetIDsOfNames(IID_NULL, (LPOLESTR*)&lpszName, 1, LOCALE_USER_DEFAULT, &dispid); if (SUCCEEDED(hr)) { DISPPARAMS dispparams = { varParams, NULL, nParams, 0}; hr = pDisp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, &varRet, NULL, NULL); } if (SUCCEEDED(hr) && varRet.boolVal==VARIANT_TRUE) return 1; else return 0;} BOOL CDjcxView::FindExecute(CString& sFindtext, CString& sReplaceText, int nWrap, int nReplace){IDispatchPtr pDisp = m_lpWord->GetApplication()->GetSelection()->GetFind();const int nParams = 11;CComVariant varParams[nParams]={nReplace,//ReplacesReplaceText,//ReplaceWithVARIANT_FALSE,//FormatnWrap,//WrapVARIANT_TRUE,//ForwardVARIANT_FALSE,//MatchAllWordFormsVARIANT_FALSE,//MatchSoundsLikeVARIANT_FALSE,//MatchWildcardsVARIANT_FALSE,//MatchWholeWordVARIANT_FALSE,//MatchCasesFindtext};//FindtextBOOL ret = InvokeN(pDisp, L"Execute", varParams, nParams);return ret;}//调用处FindExecute(sField, CString(""), Word::wdFindContinue, Word::wdReplaceAll);
方法2:regtlib "C:\Program Files\Microsoft Office\OFFICE11\msword.olb"(由于用了方法1,方法没试,我以前都是重装word解决,真傻)
参考:http://bbs.csdn.net/topics/310232353
http://support.microsoft.com/kb/292744/zh-cn?spid=3003&sid=611
- word Find->Execute 0x800706F7
- 用ASP实现超长内容的word模板替换objDoc.Content.Find.Execute
- Range.Find.Execute 占位程序接收到错误数据。
- top: cannot find/execute "top" in ISA subdirectories
- execute
- Word 提示对话框 Cannot find the Word template:WordToRqm.dot
- cannnot find the Word template : WordToRqm.dot
- cannnot find the Word template : WordToRqm.dot
- cannot find the word template:WordToRqm.dot
- Find the Longest Word in a String
- Could not find server '***' in sys.servers,Execute sp_addlinkedserver to add the server to sysy.servers
- Cannot find bin/catalina.sh The file is absent or does not have execute permission
- 循环粉碎文件:Use the find command to execute shred recursively
- cannot find the word template:WordToRqm.dot的解决方法
- cannot find the word template:WordToRqm.dot的解决方法
- cannot find the word template:WordToRqm.dot的解决方法
- Word2010--Cannot find the Word template:WordToRqm.dot的解决方法
- cannot find the word template:WordToRqm.dot的解决方法
- Elon Musk: The mind behind Tesla, SpaceX, SolarCity
- OpenStack(Grizzly) Cinder基本状态图
- 进程通信之信号通信
- 分数化小数
- Selenium 2.0 WebDriver 自动化测试 使用教程 实例教程 API快速参考
- word Find->Execute 0x800706F7
- hdmitx_boot_para_setup
- STM32 Printf函数实现方法
- Sed简明教程
- 没有W5100我们也能做yeelink的室内温度监控-基于Arduino和LM35
- 单链表的基本操作
- (English) Elon Musk: The mind behind Tesla, SpaceX, SolarCity
- 贪心-poj-2437-Muddy roads
- 网络子系统53_ip协议分片重组_内存阈值