I am currently in the process of fixing errors that showed up in C# code after it has been converted from Visual Basic. In my C# code I have the following:
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));
The problem I am having is with this section:
oRng.Information(WdInformation.wdVerticalPositionRelativeToPage)
I have the error "Indexed property 'Microsoft.Office.Interop.Word.Range.Information' has non-optional arguments which must be provided."
The type the arguments must be is WdInformation, according to msdn. I double checked and wdVerticalPositionRelativeToPage is that type. What am I doing wrong? Any help will greatly be appreciated.
If it helps, here is the same code in VB before the conversion:
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)
The error message is clearly states that the Range.Information is indexer.
Use this syntax:
oRng.Information[WdInformation.wdVerticalPositionRelativeToPage];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With