Hi people,
I have a small syntactical issue
I have outdated components list with me in a word document and i am using a small Wild card Replacement for that
Example When i do it manually ...i press find and replace and type this
---Text in document----
[Unit Name]=Carbide Grade A: K1[Internal]
[Unit Name]=Carbide Grade B: K3[Internal] and so on
i need to find the string [Unit Name]=Carbide Grade A: K1[Internal]
and replace it with [CAK1] and similarly i need to find
[Unit Name]=Carbide Grade B: K3[External] and replace it with CBK3
Manually i do it but typing this in the Find box
Unit Name=*Carbide*K1[Internal] and replace it with CAK1
But since my list is huge and there are lots of documents i am trying to make it automatic here's my code
I am getting a error on lineVB Code:
Function replwc(source As String, str_search As String, dest As String) Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .MatchWildcards = True .Text = \[\Unit Name=* & source & * & str_search & \[\Internal\] .Replacement.Text = dest .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Function Sub FrepWC() s = replwc("Carbide Grade A", "K1", "CAK1") s = replwc("Carbide Grade A", "K3", "CAK3") s = replwc("Carbide Grade B", "Q1", "CBQ1") s = replwc("Carbide Grade C", "R1", "CBR1") End Sub
VB Code:
.Text = \[\Carbide Grade A* & source & * & str_search & \[\Internal\]
How can i get this to work??
