PDA

View Full Version : BBS Tags



mikerickson
11-11-2007, 06:36 PM
I wanted to write a macro to find all underlined words and insert BBS code tags around the underlined words in a Word document.
Method 1:
Record Macro-Find-specify underline {nothing found} Stop recording.
specify font undrline (words only) nothing
font- underline (single line) nothing
font - UL with patternmatching * {finds everything}.

Method two: Save as HTML and change < to [.
Save as HTML, click on the file. It opens in Safari.
Open from Word, it converts back to formatted and doesn't show me the HTML tags.

Questions:
1)How do I get Word to find all underlined words?
2)How do I get Word to open a text file and show me the HTML tags?

Office 2004 on a Mac iBook G4 OS10.4

fumei
11-11-2007, 08:15 PM
Sub GetUnderline()
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
.ClearFormatting
.Font.Underline = wdUnderlineSingle
Do While .Execute(Forward:=True) = True
r.Font.Bold = True
r.Collapse Direction:=wdCollapseEnd
Loop
End With
End Subwill find underline (single line), and - in this case - make the found range Bold.

Replace with whatever it is you are doing. I would do that as a separate Sub, say AddBBS. Like this:Sub GetUnderline()
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
.ClearFormatting
.Font.Underline = wdUnderlineSingle
Do While .Execute(Forward:=True) = True
Call AddBBS (r)
Loop
End With
End Sub

Sub AddBBS (r As Range)
' do whatever it is you are doing
' with the found range
r.Collapse Direction:wdCollapseEnd
End Sub
You must specify the underline type.

mikerickson
11-12-2007, 10:49 AM
Thank you.