Word Document Bookmarks
Posted on 2004-08-21
I am working on a project where I need to automate MS Word and create some Documents.
I have no problems creating a word application or document object, but I do have a problem wtih the Bookmarks.
I have the following code:
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc";
object oTemplate = "C:\\temp\\Invoice.dot";
object oBookMark = "Name";
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
oDoc.Bookmarks.Item(ref oBookMark).Range.Text = "TEXT GOES HERE";
However when I build my project, I get the following error:
'Word.Bookmarks' does not contain a definition for 'Item'
Now on all the examples I have seen the above Bookmark code is used, but why do I get that error ? The Intellisense menu VS.Net pops up does not include an Item definition.
Am I not referencing something correctly ?