View Single Post
 
Old 05-09-2014, 04:51 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit 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

All you need do, then, is add bookmark to the “process document” in front of one telephone number, and cross-references to that bookmark in front of the rest of the telephone numbers, then update the bookmark with the country code, followed by .Fields.Update. However, there is an issue with the way your code currently 'updates' bookmarks. Instead of updating them, it merely inserts text after them. To update a bookmark you should use code like:
Code:
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
which you would call with code like:
Call UpdateBookmark("Address1", vbCrLf & ComboBox1)
Similarly, for adding & updating your “process document”, you might use code like:
Code:
Documents.Add Template:="File Path\Process Document.dot", NewTemplate:=False
If ComboBox1 <> "UK" Then
  Call UpdateBookmark("IDC", "+44 ")
  ActiveDocument.Fields.Update
End If
Where "IDC is the bookmark name in your “process document”, (IDC = International Dial Code).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote