Posts: 25
Threads: 12
Joined: Aug 2012
I am trying to do several search and replaces for a form we use in Microsoft Word using typelib. After a lot of searching on the forums, I am close. For example I would like to replace Not Applicable with Applicable. I would like not to use the clipboard but will if necessary. I also found that I could use key strokes after word was activated. There is a better way that I am not getting! Anyone have any ideas?
Macro
test
typelib Word {00020905-0000-0000-C000-000000000046} 8.5
Word.Document x._getfile("D:\Test.doc")
Word.Application app=x.Application
Word.Range r
app.Visible = TRUE
r=x.Range
VARIANT na="Not Applicable"
r.Find.Execute(na)
r.Select
r.Paste
Posts: 25
Threads: 12
Joined: Aug 2012
Posts: 12,092
Threads: 142
Joined: Dec 2002
Macro
Macro1961
;/exe 1
typelib Word {00020905-0000-0000-C000-000000000046} 8.5
;typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive
app.Activate
key CH ;;Ctrl+Home
app.Selection.Find.ClearFormatting()
app.Selection.Find.Text = "find me"
app.Selection.Find.Replacement.ClearFormatting()
app.Selection.Find.Replacement.Text = "Found"
VARIANT vReplace=Word.wdReplaceAll
app.Selection.Find.Execute(@ @ @ @ @ @ @ @ @ @ vReplace)
;BEGIN PROJECT
;main_function Macro1961
;exe_file $my qm$\Macro1961.qmm
;flags 6
;guid {9B9056FA-AA80-4230-B32F-D7CFE96B0668}
;END PROJECT
Posts: 25
Threads: 12
Joined: Aug 2012
Thanks Gintaras you giving me the conversion from the example I was using help tremendously with the rest of my code!