Peter -
I appreciate all of your thoughts. You have identified valid concerns that clearly must be taken into account if/when Microsoft decides to consider adding macro-building tools or options to the macro capability in the products. Of course, I don't have the
slightest idea how to get the right people at Microsoft to consider the value of adding "ease of use" improvements/tools/options to the macro capability to help non-programmer users. Maybe they'll run across this thread or perhaps someone reading this thread
will pass along the concepts to the right people".
In the meantime, perhaps you (or someone else) could assist me with the specific issue that started the thread. I have copied below a recorded macro that I would like to modify to repeat itself throughout a specific document.
The document itself has no headers, footers, footnotes, endnotes, or comments. But the information in the document (which comprises textual biographical information about hundreds of individuals and, in some instances, photos of those individuals) is repetitive
in how the information about each individual is formatted and it could be a lot more useful if the information is presented in a table.
So my goal is to be able to add either delimiters (TABS) or placeholders [e.g., (*) for later insertion of delimiters or other information using find/replace], so the information in the document ultimately can be formatted into a table. Here's the recorded
macro code:
' Macro1 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
With Selection.Find
.Text = "Published in "
.Replacement.Text = "**^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=vbTab
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "**^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.EndKey Unit:=wdLine
End Sub
Just looking at the recorded code, it looks like the macro recorder makes "assumptions" that cause it to repeatedly insert commands that I imagine a trained programmer would know how to take care of by stating them only once somewhere in the macro (such as
".Forward = True" and ".MatchCase = False"), so this probably strikes a programmer as inefficient coding. But I'm really not concerned about improving the efficiency of the existing code -- what I would like to know is the specific pieces of macro code that,
if inserted before and after this recorded macro code, would cause that recorded macro code to execute over and over from the beginning to the end of the existing document.
Is that something you can help me with?
Thanks