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

italicise quotes

0 views
Skip to first unread message

cw

unread,
Jan 9, 2008, 9:34:03 AM1/9/08
to
Hi All

I am trying to write a vba macro that will run through my document and find
any quotes (text within " " ) and format them as itallics.

i have the code below that seems to work on most of the quotes but for some
reason it misses various intances

Sub makeitalic1()
'set quotes as italics with quotemarks only
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = Chr(147) & "<*>" & Chr(148)
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
.MoveEnd Unit:=wdCharacter, Count:=-1
.MoveStart Unit:=wdCharacter, Count:=1
.Font.Italic = True
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

i have gone through my document and there seems to be a pattern emerging, it
seems to skip the quotes which have either ( ), { }, [], or ... within the
quote marks.

so a quote like

"every thing works fine on this one"

would work fine

but a quote like

"but this one has (some) troubles..."

would not be italicised

does any one know why this would happen and please guide me on how i could
capture and correct these.

Thanks very mich in advance
Craig


cw

unread,
Jan 9, 2008, 10:36:36 AM1/9/08
to

it also seems to have trouble with any quotes that have punctuation on the
end

like
"this is a quote!!!"

or "this is also a quote..."


vjp...@at.biostrategist.dot.dot.com

unread,
Jan 19, 2008, 8:25:22 AM1/19/08
to
Hi, I'm looking for similar code to italicise everything between " _"
and "_ " but then delete the "_". Also Bold between " *" and "* ".
Much obliged.


- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]

cw

unread,
Jan 22, 2008, 11:52:49 AM1/22/08
to
i found this on the web, it may help with a bit of editing the " to _ or *

Sub QuotesToItalic()
Dim Redo As Integer, Ptr As Integer, Ptr1 As Integer
Dim P As String, P1 As String
If Selection.ExtendMode Then Exit Sub
Redo = -1
While Redo
Selection.StartOf Unit:=wdParagraph, Extend:=wdMove
Selection.MoveEnd Unit:=wdParagraph
P = Selection.Text
Ptr = InStr(P, Chr(34))
If Ptr = 0 Then Ptr = InStr(P, Chr$(147))
If Ptr > 0 Then
Selection.MoveLeft Unit:=wdCharacter, Extend:=wdMove
Selection.MoveRight Unit:=wdCharacter, Count:=Ptr
Selection.MoveEnd Unit:=wdParagraph
P1 = Selection.Text
Ptr1 = InStr(P1, Chr(34))
If Ptr1 = 0 Then
Ptr1 = InStr(P1, Chr$(148))
EndChar = Chr$(148)
Else
EndChar = Chr$(34)
End If
If Ptr1 > 0 Then
Selection.MoveLeft Unit:=wdCharacter, Count:=2, _
Extend:=wdMove
Selection.Delete Unit:=wdCharacter
Selection.MoveRight Unit:=wdCharacter, _
Count:=Ptr1 - 1, Extend:=wdExtend
Selection.Font.Italic = True
Selection.MoveRight Unit:=wdCharacter, Extend:=wdMove
Selection.Delete Unit:=wdCharacter
Else
Selection.MoveRight Unit:=wdCharacter, Extend:=wdMove
Redo = 0
End If
Else
Selection.MoveRight Unit:=wdCharacter, Extend:=wdMove
Redo = 0
End If
Wend
End Sub

<vjp...@at.BioStrategist.dot.dot.com> wrote in message
news:fmsto2$2cr$2...@reader2.panix.com...

0 new messages