Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Replace html-like formatting with character formatting.

5 views
Skip to first unread message

Hans List

unread,
Nov 28, 2007, 7:41:01 AM11/28/07
to
To replace <i>html-like</i> formatting with real character formatting
I use a wildcard replacement macro (nothing special, quite well
known):

Sub test()
ResetSearch

'cursief-codes vervangen door opmaak
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Italic = True
With Selection.Find
.Text = "\<i\>(*)\</i\>"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

ResetSearch

End Sub

This macro works quite well, exept when there are {REF ...} fields
between the italics-codes.

I'm looking for a solution for this.

1. Run the macro above.
2. Check for left <i> and/or </i>
3. Run the alternative (slower?) macro to make the reference fields
italics?

What I can think of are two solutions:

1. Search for <i>. On found:
2. Turn expansion mode on
3. Search for </i>
4. Make the selection italics
5. Etc.
6. Remove the code pairs.

Or:

1. Search for <i>. On found:
2. Define a range until the next </i>, how?

Hans List

G-Money

unread,
Nov 29, 2007, 2:22:11 PM11/29/07
to
You could try opening the file/text in an HTML parser like Internet
Explorer.

Dim IEApp
Dim MyText
Set IEApp = CreateObject("InternetExplorer.Application")
IEApp.Visible = False
IEApp.Silent = True
IEApp.Navigate "MyFilePath"
Do Until Not IEApp.Busy And IEApp.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
MyText = IEApp.Document.All.tags("body").Item(0).innerText
IEApp.Quit
Set IEApp = Nothing

0 new messages