Results 1 to 4 of 4

Thread: string search and insert

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    24

    string search and insert

    I have various HTML documents and particular items have been tagged like this

    <FONT FACE="CustomFont 1" SIZE=2>2</Font>

    in the above tag the value between the font tag is 2. sometimes the value will be like this

    <FONT FACE="CustomFont 1" SIZE=2>2 3 4

    where 3 and 4 denotes some specification .

    and they have been wrongly tagged like this

    <FONT FACE="CustomFont 1" SIZE=2>2 </FONT>3 4

    whereas it should have been tagged like this

    <FONT FACE="CustomFont 1" SIZE=2>2 </FONT>
    <FONT FACE="CustomFont 1" SIZE=2>3</FONT>
    <FONT FACE="CustomFont 1" SIZE=2>4</FONT>

    Now i have many html docs like this and frankly its has given me a splitting headache...doing it manually.

    How can i find these tags and replace them

    Note Size=2 this number could vary for every tag
    "CustomFont 1" is the font that's being used.


    Thanks in advance

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: string search and insert

    Read up on the following functions :

    open
    print
    line input (or was it 'input line'?)
    replace
    instr
    close


    You should be able to code a loop to replace the fonts as required (if they are htmlm files).

    Or you can open in word and use its replace function. Similar code, but uh well word may sorta do things to the html code whilst it saves it.

    Your choice

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: string search and insert

    You're going to have to find the tag (hopefully the same tag for all) that encapsulates the string:
    <FONT FACE="CustomFont 1" SIZE=2>2 </FONT>3 4
    You will have to parse out the string then to find any hanging text after the </FONT> tag.

    Can you provide a little more of the HTML ... what tag encapsulates the string you provided?
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    24

    Re: string search and insert

    Hi,

    Webtest: The html goes like this


    <DIV CLASS=T1>
    <FONT FACE="Goudy" SIZE=2>(206 </FONT><FONT FACE="Custom Symbol 1" SIZE=2>2</FONT><FONT FACE="Goudy" SIZE=2> 190)/190 </FONT><FONT FACE="Custom Symbol 1" SIZE=2>5</FONT><FONT FACE="Goudy" SIZE=2> 8 percent.</FONT>
    </DIV>



    Now in the line
    <FONT FACE="Custom Symbol 1" SIZE=2>5</FONT>

    here i have one value "5"
    sometimes i might get 3 values

    eg: <FONT FACE="Custom Symbol 1" SIZE=2>5 2 3</FONT>

    Such occurances must be replacd like this.

    <FONT FACE="Custom Symbol 1" SIZE=2>5</FONT>
    <FONT FACE="Custom Symbol 1" SIZE=2>2</FONT>
    <FONT FACE="Custom Symbol 1" SIZE=2>3</FONT>

    I am new to VBA and i have just written some basic code till date. and since time is a constraint, this would really help me out,

    Thanks in advance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width