Thread: Bookmarks
View Single Post
 
Old 06-27-2015, 12:58 AM
Schildkröte Schildkröte is offline Windows 8 Office 2013
Novice
 
Join Date: Jun 2015
Posts: 6
Schildkröte is on a distinguished road
Default

Ok, I´m going to describe my problem more detailed:

I have a dropdown with 3 entries (Hi, Hello, Welcome).
Then I have a bookmark in this form:

Some Text
-blank space as a bookmark-
Some Text

According to what I choose I want to change the content of the bookmark.
Hi: " "
Hello: newline & "Some new Text: " & newline
Welcome: newline & a table & newline

The first two cases are not too hard I think:

This is a sub to call a makro according to which entry is choosen:

Code:
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)

Dim Text As String
Dim Empty As String
Text = vbCrLf & "Some new Text: " & vbCrLf
Empty = " "

    Select Case CC.Tag
    Case Is = "Tagname"
        Select Case CC.Range.Text
            Case Is = "Hi"
                Call ChangeText(Empty)
            Case Is = "Hello"
                Call ChangeText(Text)
            Case Is = "Welcome"
                Call ???
        End Select
    End Select

End Sub
This is a macro to change the text of a bookmark.

Code:
Sub ChangeText(ByVal Text As String)
Application.ScreenUpdating = False

    Selection.GoTo What:=wdGoToBookmark, Name:="TestBookMark"
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.InsertAfter Text
     
    ActiveDocument.Bookmarks.Add Range:=Selection.Range, _
       Name:="TestBookMark"
    Selection.Collapse

Application.ScreenUpdating = True
End Sub
But in the third case I would like to insert a table (7 rows, 2 columns) and put some text in the first column. Then everything should be the range of my bookmark again.

Appreciating your help
Reply With Quote