J
jason gefre
i'm pretty new to VBA, with most of my experience being with record macros, then tweaking a bit. I made a large macro to re-format work related items, but the find and replace ends up running through the document hundreds of times, and i was hoping there was a way to simplify the process. I was told of 'streaming' before, but i dont know how i'd implement this.
here's some examples of the code; i actually have around 100 different replacements with either a simple or wild search and a replacement
'space fixer
Call SReplaceAll(" ", " ")
Call SReplaceAll(" {2,}", " ")
'Line Fix
Call WReplaceAll("[!A-Za-z0-9\!\@\#\$\%\^\&\*\(\)\-\=\_\+\`\~\[\]\{\}\;\'\:\""\,\.\<\>\/\?\\\|
?????]", "?")
Call SReplaceAll("^l", "?")
Call WReplaceAll(" @", " ")
Call SReplaceAll(" ?", "?")
Call SReplaceAll("? ", "?")
'find average fields
'call bolder (?([A-Za-z ]{3,9}")
Call WReplaceAll("?([A-Z {3,9}", "??\1")
'kill any to/from text
Call WReplaceAll("?*?", "??")
Call WReplaceAll("[!?])??HTTP:", "\1 HTTP:")
Call SReplaceAll("?", "?")
'call sreplaceall("?","^l")
'remove page breaks
Call WReplaceAll("?{1,4}PAGE*\)", "")
'Bullets
'0.A
Call WReplaceAll("?([0-9]{1,2}).([!0-9])", "??\1.\2")
'A.1
Call WReplaceAll("?([A-Z]{1}).([!0-9])", "??\1.\2")
'(a)
'call wreplaceall("?\(([A-Z0-9]{1,2})\)","??(\1)")
' -
Call WReplaceAll("?([\- ]{1,3})", "??\1")
the subs called:
Public Sub SReplaceAll(ReplaceIn, ReplaceOut)
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ReplaceIn
.Replacement.Text = ReplaceOut
.Wrap = wdFindContinue
.MatchWildcards = False
.MatchCase = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Public Sub WReplaceAll(ReplaceIn, ReplaceOut)
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ReplaceIn
.Replacement.Text = ReplaceOut
.Wrap = wdfindcontinue
.MatchWildcards = False
.Forward = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Reflection Effect
http://www.eggheadcafe.com/tutorial...-beab-49bd76e20b9b/wpf-reflection-effect.aspx
here's some examples of the code; i actually have around 100 different replacements with either a simple or wild search and a replacement
'space fixer
Call SReplaceAll(" ", " ")
Call SReplaceAll(" {2,}", " ")
'Line Fix
Call WReplaceAll("[!A-Za-z0-9\!\@\#\$\%\^\&\*\(\)\-\=\_\+\`\~\[\]\{\}\;\'\:\""\,\.\<\>\/\?\\\|
?????]", "?")
Call SReplaceAll("^l", "?")
Call WReplaceAll(" @", " ")
Call SReplaceAll(" ?", "?")
Call SReplaceAll("? ", "?")
'find average fields
'call bolder (?([A-Za-z ]{3,9}")
Call WReplaceAll("?([A-Z {3,9}", "??\1")
'kill any to/from text
Call WReplaceAll("?*?", "??")
Call WReplaceAll("[!?])??HTTP:", "\1 HTTP:")
Call SReplaceAll("?", "?")
'call sreplaceall("?","^l")
'remove page breaks
Call WReplaceAll("?{1,4}PAGE*\)", "")
'Bullets
'0.A
Call WReplaceAll("?([0-9]{1,2}).([!0-9])", "??\1.\2")
'A.1
Call WReplaceAll("?([A-Z]{1}).([!0-9])", "??\1.\2")
'(a)
'call wreplaceall("?\(([A-Z0-9]{1,2})\)","??(\1)")
' -
Call WReplaceAll("?([\- ]{1,3})", "??\1")
the subs called:
Public Sub SReplaceAll(ReplaceIn, ReplaceOut)
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ReplaceIn
.Replacement.Text = ReplaceOut
.Wrap = wdFindContinue
.MatchWildcards = False
.MatchCase = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Public Sub WReplaceAll(ReplaceIn, ReplaceOut)
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ReplaceIn
.Replacement.Text = ReplaceOut
.Wrap = wdfindcontinue
.MatchWildcards = False
.Forward = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Reflection Effect
http://www.eggheadcafe.com/tutorial...-beab-49bd76e20b9b/wpf-reflection-effect.aspx