View Single Post
 
Old 11-04-2013, 08:00 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

A couple of things:
1. Instead of having a plethora of bookmarks for each replicated item, use just one and insert cross-references to it.
2. To correctly update the bookmarks use code like:
Code:
Private Sub btnInputData_Click()
Application.ScreenUpdating = False
Dim wdDoc As Document
Set wdDoc = ActiveDocument
Call UpdateBookmark(wdDoc, "bmSite", Me.txtSite.Value)
Call UpdateBookmark(wdDoc, "bmclient", Me.txtClient.Value)
Call UpdateBookmark(wdDoc, "bmContactNo", Me.txtContactNumber.Value)
Call UpdateBookmark(wdDoc, "bmProjectManager", Me.txtProjectManager.Value)
Call UpdateBookmark(wdDoc, "bmSupervisor", Me.txtSupervisor.Value)
Call UpdateBookmark(wdDoc, "bmProjectNo", Me.txtProjectNumber.Value)
Call UpdateBookmark(wdDoc, "bmStartDate", Me.DTPicker1.Value)
Call UpdateBookmark(wdDoc, "bmEndDate", Me.DTPicker2.Value)
'
'The rest of your code, from 'Print Sections' onwards, goes here
'
wdDoc.Fields.Update
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
'
Sub UpdateBookmark(wdDoc As Document, BmkNm As String, NewTxt As String)
Dim BmkRng As Range
With wdDoc
  If .Bookmarks.Exists(BmkNm) Then
    Set BmkRng = .Bookmarks(BmkNm).Range
    BmkRng.Text = NewTxt
    .Bookmarks.Add BmkNm, BmkRng
  End If
End With
Set BmkRng = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote