Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bookmark / Formfield updating very slow in Word VBA 2000

Status
Not open for further replies.

wiseguy62

Programmer
Aug 13, 2002
5
CA
I use the code below to search for a bookmark then replace the default value with a new string. The problem is it is very slow. I have to replace about 50 bookmarks for a form and so it takes > say 10 seconds.

I have turned off screen updating before calling this routine, but you can still see the Word document scroll bars moving as the program updates each book mark value. It seems as though the program is still somehow updating the document display - which would explain why it is so slow.

Any ideas on how to speed up this process?

'replace book mark value with new value if it exists
Public Sub ReplaceBookMarkValue(sBookMarkName As String, sBookMarkValue As String)

'Replace book mark value with value from control
If Application.ActiveDocument.Bookmarks.Exists(sBookMarkName) Then
On Error Resume Next
Selection.GoTo What:=wdGoToBookmark, Name:=sBookMarkName
Selection.FormFields(1).TextInput.EditType Type:=wdRegularText, Default:=sBookMarkValue
On Error GoTo 0
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top