Word Interop Codeblock. Working with Bookmarks/templates
-
I'm experimenting with opening a word document from a template and then changing some values. Have found some CP articles and other sources, but most of them are outdated (using interop 9 or 10 instead of 11). The problem lies here:
ApplicationClass oWordApp = new ApplicationClass(); object missing = System.Reflection.Missing.Value; object oTemplate = "RappelTemplate.dot"; Document oWordDoc = oWordApp.Documents.Add( ref oTemplate, ref missing, ref missing, ref missing); object oBookMark = "bedrag"; **oWordDoc.Bookmarks[ref oBookMark].Range.Text = "100";** oWordDoc.Activate(); oWordApp.Visible = true;
this line gives compile errors, because ref is an invalid expression term, and instead of oBookMark, "]" is expected. Nevertheless this is the only solution I can think of. It has to be ref, and it has to be oBookMark... Any hints?
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }