loops - Word Macro that would find and create hyperlink of simillar words -
so, code of macro (macro1):
sub macro1() ' ' macro1 macro ' selection.find.clearformatting selection.find .text = "req" .replacement.text = "" .forward = true .wrap = wdfindcontinue .format = false .matchcase = true .matchwholeword = false .matchwildcards = false .matchsoundslike = false .matchallwordforms = false end selection.find.execute selection.moveright unit:=wdcharacter, count:=8, extend:=wdextend selection.copy activedocument.hyperlinks.add anchor:=selection.range, address:= _ "http://www.neki.com/req12345678", subaddress:="", screentip:="", _ texttodisplay:="req12345678" end sub
the code works fine finding reqxxxxxxxx texts, pastes wrong texttodisplay , wrong ending of address. instead of req12345678 in both places should pastet same text copied before at: selection.copy. have no idea, how create loop or that, macro1 running until reaches end of document. me, please!
hey, solved 1st problem creating hyperlinks. have loop "hyperlink" macro. decided create macro, loop first one. here code:
sub macro2() ' ' macro2 macro ' until activedocument.bookmarks.exists("konec") application.run macroname:="macro1" loop end sub
macro1 works fine, can't figure out how loop until end of document - until ending bookmark...
i used following code link selected text similar text appears later in document.
sub macro1() ' ' macro1 macro ' ' selection.find .text = selection .replacement.text = "" .forward = true .wrap = wdfindcontinue .format = false .matchcase = true .matchwholeword = true .matchwildcards = true .matchsoundslike = false .matchallwordforms = false end selection.find.execute activedocument.bookmarks .add range:=selection.range, name:=selection .defaultsorting = wdsortbyname .showhidden = false end selection.find .text = selection .replacement.text = "" .forward = false .wrap = wdfindcontinue .format = false .matchcase = true .matchwholeword = true .matchwildcards = true .matchsoundslike = false .matchallwordforms = false end selection.find.execute activedocument.hyperlinks.add anchor:=selection.range, address:="", _ subaddress:=selection, screentip:="", texttodisplay:=selection end sub
Comments
Post a Comment