环境:win7 64位,vs2010,word2010
c#源码:
try
{
MSWord.Range rFind = rangeFind.Parent as MSWord.Range;
for (int i = 1; i <= rFind.Characters.Count; i++)
{
string str = rFind.Characters[i].Text;
}
}
catch(Exception ex)
{
}
注意:这里for循环是从1开始的,若从0开始,会报0x800a1735异常
- ex {"集合所要求的成员不存在。"} System.Exception {System.Runtime.InteropServices.COMException}
+ [System.Runtime.InteropServices.COMException] {"集合所要求的成员不存在。"} System.Runtime.InteropServices.COMException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HelpLink "wdmain11.chm#25421" string
HResult 0x800a1735 int
+ InnerException null System.Exception
Message "集合所要求的成员不存在。" string
Source "Microsoft Word" string
StackTrace " at Microsoft.Office.Interop.Word.Characters.get_Item(Int32 Index)\r\n at CesClient.Base.Command.WordOperator.DoFindingByRegex(String strregex, Boolean bparabegin, streamrange srg) in D:\\source\\WordClient\\Base\\Command\\DocOperator.cs:line 214" string
+ TargetSite {Microsoft.Office.Interop.Word.Range get_Item(Int32)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+ Static members
+ Non-Public members
参考:http://blog.163.com/freemailforme@126/blog/static/3442753120082209425698/