Hello. I have the following Word-Interop code. How can I use the Word enumerations in this code? At the moment I am use the integer 6 which I know to be the value of wdStory in the Word object library, and even 1 for true.
Doh! 2 seconds after posting this I had some inspiration:
but I still need the value for true?
using System;
using System.Text;
using Microsoft.Office.Interop.Word;
namespace ConsoleAppWord {
class Program {
public void ProcessDocument(Document aDoc) {
}
static void Main(string[] args) {
Application wdApp = new Application();
Document wdDoc;
try {
wdApp.Visible = true;
//wdDoc = wdApp.Documents.Add();
wdDoc = wdApp.Documents.Open("C:\\Users\\Andrew\\Documents\\Somewhere.docx");
wdApp.Selection.EndKey(6); // wdStory
wdApp.Selection.TypeText("Hello Word!");
wdApp.Selection.TypeParagraph();
wdApp.Selection.TypeParagraph();
wdApp.Selection.TypeText("Goodbye Word!");
wdDoc.Paragraphs[1].Range.Font.Bold = 1;
wdDoc.SaveAs("C:\\Users\\Andrew\\Documents\\Somewhere");
((_Application) wdApp).Quit(); // prevent ambiguity message
} catch (Exception ex) {
Console.WriteLine(ex.Message);
throw;
} finally {
System.Runtime.InteropServices.Marshal.ReleaseComObject(wdApp);
}
}
}
}
Doh! 2 seconds after posting this I had some inspiration:
wdApp.Selection.EndKey(Unit : WdUnits.wdStory);
but I still need the value for true?