我目前正在修复 C# 代码从 Visual Basic 转换后出现的错误。在我的 C# 代码中,我有以下内容:
Pos = oWord.InchesToPoints(7);
oDoc.Bookmarks["\\endofdoc"].Range.InsertParagraphAfter();
do
{
oRng = oDoc.Bookmarks["\\endofdoc"].Range;
oRng.ParagraphFormat.SpaceAfter = 6;
oRng.InsertAfter("");
oRng.InsertParagraphAfter();
} while (Pos >= oRng.Information(WdInformation.wdVerticalPositionRelativeToPage));
我遇到的问题是这部分:
oRng.Information(WdInformation.wdVerticalPositionRelativeToPage)
我遇到错误“索引属性‘Microsoft.Office.Interop.Word.Range.Information’具有必须提供的非可选参数。”
根据 msdn,参数的类型必须是 WdInformation。我仔细检查了一下,wdVerticalPositionRelativeToPage 就是那种类型。我究竟做错了什么?任何帮助将不胜感激。
如果有帮助,下面是转换前 VB 中的相同代码:
Pos = oWord.InchesToPoints(7)
oDoc.Bookmarks.Item("\endofdoc").Range.InsertParagraphAfter()
Do
oRng = oDoc.Bookmarks.Item("\endofdoc").Range
oRng.ParagraphFormat.SpaceAfter = 6
oRng.InsertAfter("")
oRng.InsertParagraphAfter()
Loop While Pos >= oRng.Information(Word.WdInformation.wdVerticalPositionRelativeToPage)
最佳答案
错误消息明确指出 Range.Information
是索引器。
使用这个语法:
oRng.Information[WdInformation.wdVerticalPositionRelativeToPage];
关于c# - Range.Information 不工作 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27026729/