Arrow123
06-07-2012, 04:25 PM
I have made a user form that has several check boxes. When a particular check box is true, a series of searches and replaces is performed on the text of a document; then on the footnotes; then on the endnotes. Here is a sample.
If chkshortinclusnos = True Then
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "( )([1-9])([0-9])(^=)([0-9])(,)"
.Replacement.Text = "\1\2\3\4\2\5\6"
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
If ActiveDocument.Footnotes.Count > 0 Then
ActiveWindow.View.SeekView = wdSeekFootnotes
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "( )([1-9])([0-9])(^=)([0-9])(,)"
.Replacement.Text = "\1\2\3\4\2\5\6"
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
and so on.
After switching to footnote view (or endnote view), is there any way to repeat the series of searches and replaces that was done in the text, without repeating the code itself? I am a complete novice at Visual Basic and don't have any idea how to proceed. I tried repeating
chkshortinclusnos = True
but it didn't work.
Thanks for any help. And sorry if this is something so simple I shouldn't even be asking.
If chkshortinclusnos = True Then
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "( )([1-9])([0-9])(^=)([0-9])(,)"
.Replacement.Text = "\1\2\3\4\2\5\6"
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
If ActiveDocument.Footnotes.Count > 0 Then
ActiveWindow.View.SeekView = wdSeekFootnotes
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "( )([1-9])([0-9])(^=)([0-9])(,)"
.Replacement.Text = "\1\2\3\4\2\5\6"
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
and so on.
After switching to footnote view (or endnote view), is there any way to repeat the series of searches and replaces that was done in the text, without repeating the code itself? I am a complete novice at Visual Basic and don't have any idea how to proceed. I tried repeating
chkshortinclusnos = True
but it didn't work.
Thanks for any help. And sorry if this is something so simple I shouldn't even be asking.