View Single Post
 
Old 07-20-2023, 02:33 PM
gmaxey gmaxey is offline Windows 10 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

I don't want anything. You are the one who came here looking for help. You mention that you have experience with Excel and Access. A function in Word is nothing like a function that you might enter into an Excel field.


Typically with a Word VBA "function," you will pass arguments to it and it returns a value:
Code:
Sub Demo()
  MsgBox Add(2.5, 1.5), vbOKOnly, "SUM"
End Sub


Function Add(a, b) As Single
  Add = a + b
End Function

Your function will return the value (and place it at the end of a document, a table cell, a content control or whatever target you define) each time you run it. Word has no built-in change event that automatically detects a user adding text (or specific characters in your case) or calls a procedure e.g., your function.


Now, if you put a content control adjacent to each of your objectives and use it to enter your "**" marks then you could use the Document _ContentControlOnExit event to call your function.



Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
'Call your function here.
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote