| JREF Homepage | Swift Blog | Events Calendar | $1 Million Paranormal Challenge | The Amaz!ng Meeting | Useful Links | Support Us |
![]() |
|
|
|
|||||||
| Notices |
| Welcome to the JREF Forum, where we discuss skepticism, critical thinking, the paranormal and science in a friendly but lively way. You are currently viewing the forum as a guest, which means you are missing out on discussing matters that are of interest to you. Please consider registering so you can gain full use of the forum features and interact with other Members. Registration is simple, fast and free! Click here to register today. |
|
|
#1 |
|
Wag
Join Date: Jul 2003
Location: London, Ontario
Posts: 2,761
|
Word Macro Help
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 |
|
__________________
Major General Wag of JREF |
|
|
|
|
|
#2 |
|
Critical Thinker
Join Date: Mar 2006
Posts: 341
|
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
|
|
|
|
|
#3 |
|
Wag
Join Date: Jul 2003
Location: London, Ontario
Posts: 2,761
|
|
|
__________________
Major General Wag of JREF |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|