vba - How to hide the data in between the two tags(<hidden> ...... </hidden>) in Word document -


need code such that... data ever present between 2 tags should hidden.. sake did firstly searched tagin document , replaced tag registered symbol(®) , range . need code in way without replacing tag

sub test() dim long = 0 dim myword string myword = "®" targetlist = array("</hidden>") activedocument.content.find      .text = "</hidden>"      .replacement.text = myword      .wrap = wdfindcontinue      .execute replace:=wdreplaceall end    counter = 1 set range = activedocument.range selection.homekey unit:=wdstory selection.find     .forward = true     .wrap = wdfindstop     .text = "<hidden>" while .execute     counter = counter + 1 wend end = 0 counter set range = activedocument.range selection.homekey unit:=wdstory selection.find     .forward = true     .wrap = wdfindstop     .text = "<hidden>" if .execute(forward:=true) = true selection.range selection.moveenduntil cset:="®", count:=wdforward selection.moveright unit:=wdcharacter, count:=1, extend:=wdextend selection.font.hidden = true end end if end next end sub 

you can achieve using simple word find , replace using wild cards:

with selection.find     .clearformatting     .clearallfuzzyoptions      .text = "[<]hidden[>](*)[<]/hidden[>]"     .forward = true     .wrap = wdfindcontinue     .format = true     .matchcase = false     .matchwholeword = false     .matchallwordforms = false     .matchsoundslike = false     .matchwildcards = true      .replacement.text = ""     .replacement.clearformatting      .replacement.font.hidden = true      .execute replace:=wdreplaceall end 

if want remove tags well, use following replacement text:

    .replacement.text = "\1" 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -