![]() |
|
#2
|
||||
|
||||
|
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] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Replacing text with user input.?.?.?
|
brad1977 | Word | 3 | 11-20-2012 10:20 AM |
Open header to insert text into bookmark
|
Amapola188 | Word VBA | 3 | 07-12-2012 05:16 PM |
| Repeating Bookmark Text | BECKTHOMO | Word | 1 | 03-27-2012 08:34 PM |
Word 2003 - IncludeText Does Not Include Bookmark Text if in a Form Text Control
|
skarden | Word | 1 | 12-12-2011 10:39 PM |
delete all bookmark text
|
hklein | Word VBA | 4 | 08-10-2011 04:33 AM |