Travis Lingenfelder was telling us:
Travis Lingenfelder nous racontait que :
> I am creating an application that uses Word to producce reports using
> COM Interop. I have created a Word template that contains named
[quoted text clipped - 5 lines]
> I right-click where the bookmark sould be I can click Toggle field
> codes and the data for the field is something like"{ insertedText }".
It would be most helpful if you posted the relevant part of the code that
are inserting the text at the bookmarked areas.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Travis Lingenfelder - 19 Nov 2004 19:51 GMT
Sorry, I meant to post the code with my previous post.
Here is the procedure to replace the text in a Named Bookmark
private void BookMarkReplaceRange(string bookmarkName, string newText)
{
object oBookmarkName = bookmarkName;
Word.Range rng = wrdDoc.Bookmarks.get_Item(ref oBookmarkName).Range;
rng.Text = newText;
object oRng = rng;
wrdDoc.Bookmarks.Add(bookmarkName, ref oRng);
}
> Travis Lingenfelder was telling us:
> Travis Lingenfelder nous racontait que :
[quoted text clipped - 11 lines]
> It would be most helpful if you posted the relevant part of the code that
> are inserting the text at the bookmarked areas.
It sounds like you're not updating the text in the bookmark properly. You
should be using a line like the below (for the simplest case):
ActiveDocument.Bookmarks("MyBookMarkName").Range.Text = "new text which
overwrites the previous text"
The above however will delete the bookmark after it's updated; if you will
need to reference it by name after the update, you'll need a general purpose
subroutine for updating bookmarks which leaves them in place, like the one
below:
Public Sub UpdateBookmark(ByVal BookmarkToUpdate As String, ByVal TextToUse
As String)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
BMRange.Text = TextToUse
ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange
End Sub
hth,
Chip
> I am creating an application that uses Word to producce reports using COM
> Interop. I have created a Word template that contains named bookmarks
[quoted text clipped - 7 lines]
>
> How can I get the insertedText to display properly?