vik1
04-22-2016, 08:43 AM
How can I call a word vba macro code from a VB Script:
the word vba macro code is under:
Sub find_replace_vik_42216()
Application.ScreenUpdating =False
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text ="abc"
.Replacement.Text ="def"
.Forward =True
.Wrap = wdFindContinue
.Format =False
.MatchCase =False
.MatchWholeWord =False
.MatchWildcards =False
.MatchSoundsLike =False
.MatchAllWordForms =False
EndWith
With Selection
If.Find.Forward =TrueThen
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
EndIf
.Find.Execute Replace:=wdReplaceOne
EndWith
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text ="pqr"
.Replacement.Text ="xyz"
.Forward =True
.Wrap = wdFindContinue
.Format =False
.MatchCase =False
.MatchWholeWord =False
.MatchWildcards =False
.MatchSoundsLike =False
.MatchAllWordForms =False
EndWith
With Selection
If.Find.Forward =TrueThen
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
EndIf
.Find.Execute Replace:=wdReplaceOne
EndWith
Application.ScreenUpdating =True
EndSub
could dear members create a vb script file which contains the above code, so that I call the vb script to run this code.
I have wrecked my brains and troubled google, to no avail. Please help.
Thank you.
Vik
the word vba macro code is under:
Sub find_replace_vik_42216()
Application.ScreenUpdating =False
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text ="abc"
.Replacement.Text ="def"
.Forward =True
.Wrap = wdFindContinue
.Format =False
.MatchCase =False
.MatchWholeWord =False
.MatchWildcards =False
.MatchSoundsLike =False
.MatchAllWordForms =False
EndWith
With Selection
If.Find.Forward =TrueThen
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
EndIf
.Find.Execute Replace:=wdReplaceOne
EndWith
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text ="pqr"
.Replacement.Text ="xyz"
.Forward =True
.Wrap = wdFindContinue
.Format =False
.MatchCase =False
.MatchWholeWord =False
.MatchWildcards =False
.MatchSoundsLike =False
.MatchAllWordForms =False
EndWith
With Selection
If.Find.Forward =TrueThen
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
EndIf
.Find.Execute Replace:=wdReplaceOne
EndWith
Application.ScreenUpdating =True
EndSub
could dear members create a vb script file which contains the above code, so that I call the vb script to run this code.
I have wrecked my brains and troubled google, to no avail. Please help.
Thank you.
Vik