stoicw
03-27-2018, 11:12 AM
Hi,
I am trying to format my word document to include HTML "tags". In the context of word, it is useless, but I will be copying this text and posting it in a HTML Text box.
I have 2 separate macros. and I wan't to add a third function.
But I also want to combine all three into one macro so that I don't have to run all three, I can just run one.
The function I don't have that I want to add, is the addition of <p> at the start of each paragraph, and have </p> at the end.
And I'd also like to know how I can combine these 3 functions into one macro.
HTML Tags:
Sub HTMLTag()'
' HTMLTag Macro
Selection.Find.Style = ActiveDocument.Styles("Emphasis")
With Selection.Find
.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.ClearFormatting
.Font.Bold = True
With .Replacement
.ClearFormatting
.Text = "<b>^&</b>"
.Font.Bold = False
End With
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Font.Italic = True
With .Replacement
.ClearFormatting
.Text = "<i>^&</i>"
.Font.Italic = False
End With
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Font.Underline = True
With .Replacement
.ClearFormatting
.Text = "<u>^&</u>"
.Font.Underline = False
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
HTML Breaks:
Sub HTMLBreak()
'
' HTMLBreak Macro
Selection.Find.Style = ActiveDocument.Styles("Emphasis")
With Selection.Find
.Text = "***"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.ClearFormatting
.Font.Bold = False
With .Replacement
.ClearFormatting
.Text = "<hr/>"
.Font.Bold = False
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
Thank you so much!
I am trying to format my word document to include HTML "tags". In the context of word, it is useless, but I will be copying this text and posting it in a HTML Text box.
I have 2 separate macros. and I wan't to add a third function.
But I also want to combine all three into one macro so that I don't have to run all three, I can just run one.
The function I don't have that I want to add, is the addition of <p> at the start of each paragraph, and have </p> at the end.
And I'd also like to know how I can combine these 3 functions into one macro.
HTML Tags:
Sub HTMLTag()'
' HTMLTag Macro
Selection.Find.Style = ActiveDocument.Styles("Emphasis")
With Selection.Find
.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.ClearFormatting
.Font.Bold = True
With .Replacement
.ClearFormatting
.Text = "<b>^&</b>"
.Font.Bold = False
End With
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Font.Italic = True
With .Replacement
.ClearFormatting
.Text = "<i>^&</i>"
.Font.Italic = False
End With
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Font.Underline = True
With .Replacement
.ClearFormatting
.Text = "<u>^&</u>"
.Font.Underline = False
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
HTML Breaks:
Sub HTMLBreak()
'
' HTMLBreak Macro
Selection.Find.Style = ActiveDocument.Styles("Emphasis")
With Selection.Find
.Text = "***"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.ClearFormatting
.Font.Bold = False
With .Replacement
.ClearFormatting
.Text = "<hr/>"
.Font.Bold = False
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
Thank you so much!