直接上代码
object fileName = "f:\\test.doc";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
ApplicationClass oWordApp = new ApplicationClass();
Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing, ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing);
var comdoc = oWordDoc.ActiveWindow.Panes[1];
var panes=comdoc.Pages;
for (int i=1; i<panes.Count; i++)
{
panes[i]; //此处为什么panes[i]总是出错"集合所要求的成员不存在"
}
oWordDoc.Activate();
oWordApp.Selection.TypeText("This is the text");
oWordApp.Selection.TypeParagraph();
oWordDoc.Save();
请大家帮我看看那出错了。。先谢谢各位了。。。。
------解决方案-------------------- for (int i=0; i<panes.Count; i++)
{
panes[i]; //此处为什么panes[i]总是出错"集合所要求的成员不存在"
}
循环从0开始.
------解决方案--------------------comdoc 获取的是一个 int类型的吧?、、panes什么时候变成了数组了,你断点调试,看这几个的值是什么
------解决方案--------------------