Hi,
This is my first post here and I hope someone can help me with my problem. I want to add text to existing bookmark in a word file from my C# program. The code I have now seems to work but I dont know how to add text to the bookmark.
Take a look at this,
Object fileName = "\\test.dot";
Object readOnly = false;
Object isVisible = true;
Object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document wordDoc = new Microsoft.Office.Interop.Word.Document();
wordApp.Visible = true;
wordDoc = wordApp.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 isVisible, ref missing, ref missing, ref missing, ref missing);
string Test = "Test";
object bookmarkName = "Name";
if (wordDoc.Bookmarks.Exists(bookmarkName.ToString()) )
{
'Code for adding text to bookmark
}
wordApp.Documents.Close();
Okay, so the Test variable with the text "Test" should be placed in the bookmark named "Name".
Im working with Microsoft Visual C# 2010 Express