• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Word Macro Help

Joined
Jul 8, 2003
Messages
2,760
I'm trying to write a Word 2003 macro that will find all italic text and just add a single space in front of the italic text.

Before: some crazy textITALIC, some moreITALIC.
After : some crazy text ITALIC, some more ITALIC.

S'cuse my lack of HTML skills to even show the example with real italics.

The reason I need the macro is that I have some books stored in LIT format. I have a spiffy utility that converts the LIT files to RTF, but somehow flows italics into the previous word or symbol.

Any help will be appreciated ....

Charlie (lost in MS Word VBA) Monoxide
 
I'm trying to write a Word 2003 macro that will find all italic text and just add a single space in front of the italic text.

Before: some crazy textITALIC, some moreITALIC.
After : some crazy text ITALIC, some more ITALIC.

S'cuse my lack of HTML skills to even show the example with real italics.

The reason I need the macro is that I have some books stored in LIT format. I have a spiffy utility that converts the LIT files to RTF, but somehow flows italics into the previous word or symbol.

Any help will be appreciated ....

Charlie (lost in MS Word VBA) Monoxide

I'm not really a VBA guy, but here's my clumsy hacked attempt at this:

Code:
Sub italicSpacer()
'
' italicSpacer Macro
' Macro created 1/14/2007 by Joe Burks
'
    Dim blnSearchAgain As Boolean
    ' Search from the top of the document
    Selection.HomeKey Unit:=wdStory
    
    ' Change this to False if you want to replace one-by-one
    blnSearchAgain = True
    Do
        ' Search for some italicized text
        With Selection.Find
            .ClearFormatting
            .Text = ""
            .Font.Italic = True
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindStop
            .Execute
        End With
        
        If Selection.Find.Found Then
            ' If some was found, put a space in front of it
            Selection.Text = " " + Selection.Text
            Selection.MoveRight
        Else
            ' Nothing found, we're done!
            blnSearchAgain = False
        End If
    Loop While blnSearchAgain
End Sub

Give it a shot, it seems to work with your example. This is probably my first VBA script since Word 5 (circa 1995), so take with appropriate sized grain of salt (maybe someone here who actually likes this sad excuse for Basic can fix any problems herein.)
 
I'm not really a VBA guy, but here's my clumsy hacked attempt at this:

code removed ....

Give it a shot, it seems to work with your example. This is probably my first VBA script since Word 5 (circa 1995), so take with appropriate sized grain of salt (maybe someone here who actually likes this sad excuse for Basic can fix any problems herein.)
Works great! Much appreciated for the quick response!

You'll go to heaven if you're so inclined to believe ....

Charlie (off to format some LIT files) Monoxide
 

Back
Top Bottom