View Single Post
 
Old 01-13-2015, 09:20 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Ideally, you'd only press Enter once. However, the basic problem is that you're not updating the bookmarks - you're simply using them as placeholders to insert the text. To update the bookmarks, you should be using code like:
Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Call UpdateBookmark("Snr", Me.TextBox1.Value)
Call UpdateBookmark("Bes", Me.TextBox2.Value)
Call UpdateBookmark("Ini", Me.TextBox3.Value)
Application.ScreenUpdating = True
UserForm1.Hide
End Sub
 
Sub UpdateBookmark(StrBkMk As String, StrTxt As String)
Dim BkMkRng As Range
With ActiveDocument
  If .Bookmarks.Exists(StrBkMk) Then
    Set BkMkRng = .Bookmarks(StrBkMk).Range
    BkMkRng.Text = StrTxt
    .Bookmarks.Add StrBkMk, BkMkRng
  End If
End With
Set BkMkRng = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote