Editing text at a bookmark

W

William Holmes

Hello,

I want to update a bookmark with new text using Microsoft Word 2003 and C#
Visual Studio 2005. I have not done this before and I am having trouble. If
anyone could help me I would appreicate it. I know the names of all the
bookmarks (there are only four) If I run this code in debug I see the
bookMarks colllection object but I don't understand how to access the
individaul bookmarks and update their text. I would really appreciate a
couple of pointers.

Thanks

Bill


Here is my code so far.



object varFileName = @"d:\projects\newuser.dot";
object varFalseValue = false;
object varTrueValue = true;
object varMissing = Type.Missing;

Microsoft.Office.Interop.Word.Application varWord = new
Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document varDoc =
varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing, ref varMissing,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing);

// Activate the document

varDoc.Activate();
varWord.Visible = true;
Microsoft.Office.Interop.Word.Bookmarks bookMarks = varDoc.Bookmarks;
int count = bookMarks.Count;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top