Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Fri, 4 Apr 2008 08:16:21 +1100,    group: microsoft.public.word.vba.beginners        back       


HTML codes convert to Attribute   
Client sends documents with typesetting codes - how do I find/replace the 
bold, italic and bold/italic and add the attribute to the text in html code 
and remove the html code in a loop? Is it possible to do in one macro guys?

This is a test paragraph showing both the <B>bold terms<B> and words, as
well as the <I>italicized areas<I> and the <BI>bold, italicized
words.<BI>
date: Fri, 4 Apr 2008 08:16:21 +1100   author:   PeterJ

Re: HTML codes convert to Attribute   
Dim myrange As Range, srange As Range, erange As Range
Dim i As Long, j As Long
Dim fcode As String
    For i = 1 To 3
        If i = 1 Then
            fcode = "\<B\>*\<B\>"
            j = 3
        ElseIf i = 2 Then
            fcode = "\<I\>*\<I\>"
            j = 3
        Else
            fcode = "\<BI\>*\<BI\>"
            j = 4
        End If
        Selection.HomeKey wdStory
        Selection.Find.ClearFormatting
        With Selection.Find
            Do While .Execute(findText:=fcode, Forward:=True, _
                MatchWildcards:=True, Wrap:=wdFindStop) = True
                Set myrange = Selection.Range
                If i = 1 Then
                    myrange.Font.Bold = True
                ElseIf i = 2 Then
                    myrange.Font.Italic = True
                Else
                    myrange.Font.Bold = True
                    myrange.Font.Italic = True
                End If
                Set srange = myrange.Duplicate
                Set erange = myrange.Duplicate
                srange.End = srange.start + j
                srange.Delete
                erange.start = erange.End - j
                erange.Delete
            Loop
        End With
    Next i

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"PeterJ"  wrote in message 
news:OfygeAdlIHA.5396@TK2MSFTNGP04.phx.gbl...
> Client sends documents with typesetting codes - how do I find/replace the 
> bold, italic and bold/italic and add the attribute to the text in html 
> code and remove the html code in a loop? Is it possible to do in one macro 
> guys?
>
> This is a test paragraph showing both the <B>bold terms<B> and words, as
> well as the <I>italicized areas<I> and the <BI>bold, italicized
> words.<BI>
>
>
>
>
date: Fri, 4 Apr 2008 19:03:43 +1000   author:   Doug Robbins - Word MVP

Re: HTML codes convert to Attribute   
Wow, thank you Doug you are fabulous!

"Doug Robbins - Word MVP"  wrote in message 
news:uAcGNLjlIHA.4480@TK2MSFTNGP03.phx.gbl...
> Dim myrange As Range, srange As Range, erange As Range
> Dim i As Long, j As Long
> Dim fcode As String
>    For i = 1 To 3
>        If i = 1 Then
>            fcode = "\<B\>*\<B\>"
>            j = 3
>        ElseIf i = 2 Then
>            fcode = "\<I\>*\<I\>"
>            j = 3
>        Else
>            fcode = "\<BI\>*\<BI\>"
>            j = 4
>        End If
>        Selection.HomeKey wdStory
>        Selection.Find.ClearFormatting
>        With Selection.Find
>            Do While .Execute(findText:=fcode, Forward:=True, _
>                MatchWildcards:=True, Wrap:=wdFindStop) = True
>                Set myrange = Selection.Range
>                If i = 1 Then
>                    myrange.Font.Bold = True
>                ElseIf i = 2 Then
>                    myrange.Font.Italic = True
>                Else
>                    myrange.Font.Bold = True
>                    myrange.Font.Italic = True
>                End If
>                Set srange = myrange.Duplicate
>                Set erange = myrange.Duplicate
>                srange.End = srange.start + j
>                srange.Delete
>                erange.start = erange.End - j
>                erange.Delete
>            Loop
>        End With
>    Next i
>
> -- 
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "PeterJ"  wrote in message 
> news:OfygeAdlIHA.5396@TK2MSFTNGP04.phx.gbl...
>> Client sends documents with typesetting codes - how do I find/replace the 
>> bold, italic and bold/italic and add the attribute to the text in html 
>> code and remove the html code in a loop? Is it possible to do in one 
>> macro guys?
>>
>> This is a test paragraph showing both the <B>bold terms<B> and words, as
>> well as the <I>italicized areas<I> and the <BI>bold, italicized
>> words.<BI>
>>
>>
>>
>>
>
>
date: Fri, 4 Apr 2008 20:54:59 +1100   author:   PeterJ

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us