none
Is it possible to mark a region in Word document RRS feed

  • Question

  • Here is what I would like to do. I would like to generate some custom text (with content controls and other word artifacts), but I also want to mark start and end of auto-generated region. This way I can easily delete this region or re-generate it if needed. End and start don't have to be visible in Word.

    Is there any way to do this in Word? I tried to think about construction in Word which can accomplish, but nothing come to mind.

     


    Victor - Lead Software Developer
    TeamLook - TFS Outlook Integration
    TeamSpec - TFS Requirements Management Integration
    Thursday, May 19, 2011 4:30 PM

Answers

  • Bookmarks I think are your answer. The following is VB .Net code to write to an existing bookmark.

    Sub WriteTextToBookmark(ByVal doc As Word.Document, ByVal bkmName As String, ByVal newText As String)

            Dim rng As Word.Range

            If doc.Bookmarks.Exists(bkmName) Then

                rng = doc.Bookmarks.Item(bkmName).Range

                rng.Text = newText

                doc.Bookmarks.Add(bkmName, rng)

            End If

        End Sub

    For more info, here is a link.

    http://msdn.microsoft.com/en-us/library/5eef9s6f(v=VS.100).aspx


    Wag and they wag with you, Howl and they put you outside. http://greatcirclelearning.com
    • Marked as answer by victor-pd Friday, May 20, 2011 12:06 AM
    Thursday, May 19, 2011 8:25 PM

All replies

  • Bookmarks I think are your answer. The following is VB .Net code to write to an existing bookmark.

    Sub WriteTextToBookmark(ByVal doc As Word.Document, ByVal bkmName As String, ByVal newText As String)

            Dim rng As Word.Range

            If doc.Bookmarks.Exists(bkmName) Then

                rng = doc.Bookmarks.Item(bkmName).Range

                rng.Text = newText

                doc.Bookmarks.Add(bkmName, rng)

            End If

        End Sub

    For more info, here is a link.

    http://msdn.microsoft.com/en-us/library/5eef9s6f(v=VS.100).aspx


    Wag and they wag with you, Howl and they put you outside. http://greatcirclelearning.com
    • Marked as answer by victor-pd Friday, May 20, 2011 12:06 AM
    Thursday, May 19, 2011 8:25 PM
  • I think bookmarks is what I need. I knew about them, but for some reason I thought you cannot have content controls inside a bookmark.

     

    Thanks,

    Victor

    Friday, May 20, 2011 12:06 AM