Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-20-2023, 10:31 AM
gmaxey gmaxey is offline Use a custom function in Word to count specific characters Windows 10 Use a custom function in Word to count specific characters Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Function ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim strSearch As String
Dim iCount As Long, Hecho As Single
  strSearch = "**"
  iCount = 0
  With ActiveDocument.Content.Find
    .Text = strSearch
    .Format = False
    .Wrap = wdFindStop
    Do While .Execute
        iCount = iCount + 1
    Loop
End With
  Hecho = iCount / 2
  'at end of document.
  ActiveDocument.Range.InsertAfter vbCr & Hecho
  'in a content control titled Hecho.
  ActiveDocument.SelectContentControlsByTitle("Hecho").Item(1).Range.Text = Hecho
  'in an table (first table, first cell)
  ActiveDocument.Tables(1).Cell(1, 1).Range.Text = Hecho
End
lbl_Exit:
  Exit Function
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a custom function in Word to count specific characters Select a specific number of characters in word using VBA mrwoggie Word VBA 1 01-18-2022 03:08 PM
Looking for a macro for word count in one specific column of table, only rows with white background mobj Word VBA 2 10-17-2019 03:09 AM
Use a custom function in Word to count specific characters Deleting Characters in a specific location in Word 2010 ppayaw Word VBA 8 12-13-2016 08:11 AM
Use a custom function in Word to count specific characters Custom ribbon button or shortcut for a specific function Nicobisgaard Word 6 04-22-2015 04:39 AM
Use a custom function in Word to count specific characters Count characters on the fly NobodysPerfect Word VBA 1 04-20-2014 03:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft