index > Visual Basic for Applications (VBA) > Need to Count the replacements made by a VBA macro in a Word 2003...

Need to Count the replacements made by a VBA macro in a Word 2003...


We have a bunch of VBA that does a lot of cleanup work in some fancy documents. As these VBA run we would like to display the amount of changes made to the document. Is that possible?
Jim Dunn
Yes. We can do.

Example:
Dim cou as integer
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = FindText
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
While .Execute
cou=cou+1
'Write code to replace selection text here
Selection.Collapse direction:=wdCollapseEnd
Wend
End With
Msgbox cou

-bvr
bvravi
reply 2

You can use google to search for other answers

 

More Articles

• [Access 2000] Error when importing text files of certain extensio...
• graphic on/off
• What is the difference between SET and Assigning a value to a var...
• saving exel data
• Filling data from one sheet to another (excel)
• Dump data into 2 databases automatically
• Disabling enter and mouse click PPT navigation
• Close Access Form After Video playing
• Error Referencing DLL in VBA
• How do I...
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Copying selected Worksheets to new workb
• Can no longer enter wscript for debug
• VBA runs slowly in Excel 97
• how to open read only file that will be
• vba array?
• menu tiems for OutputToText, OutputToExc
• MultiPage problem!
• Select line of text in Word documents
• Adding Appts to a Group Calendar
• Dynamicaly enter Data in Microsoft Access
• Diasbling Security settings in Microsoft
• Pull data from .csv files into one main
• Autosave using VBA after n minutes
• What is an error 400?
• excel formula

Hot Articles

• No Database Type
• row height
• Acces functions in my ouwn services appl
• After_Save Event???
• pass parameter to stored procedure
• need help with email attachement
• ACCESS 2003 OLE
• Size Form to fit user resolution
• Accessing control textbox text
• Loop til you drop
• Error 3251 using ADO & VBA to drop a
• Detect visio shape double click
• open powerpoint slide from another power
• Excel - squares appear when sending info
• File name - VBA for powerpoint

Recommend Articles

• Help to create a new table using VBA codes
• day of the week
• Microsoft Document Image Printer - MODI
• Input from user form put into specified
• Access and VBA application in the mdb file
• No Database Type
• VBA for Excel Query. From Someone New
• Excel Pivot Tables - Dynamically Changin
• MS Access, how to mazimize a form's wind
• Outlook experienced a serious error: 'mi
• Challenge writing a macro for setting Me
• Vb migration to Access 2003
• Wildcards In Access
• Copy Outlook email into Excel
• Linking Outlook to Excel