adding quotation marks around a selection (can you help me tweak this code?)
I think that the yen character is unnecessary and that
Selection.TypeText Text:=Chr(148) & " on page "
alone should give you the " (the closing curly quote in case it does not
come out in your newsreader)
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Tom" wrote in message
ups.com...
All right. I've been toying with this for the past hour and found a
circus-like workaround.
To insert the quotation mark in the front of the selection, I just
added Selection.TypeText Text:=Chr(147) before the macro inserts the
reference. That's fine.
But I was still getting a backwards quotation mark when I inserted the
later reference. So I added a yen character chr(165) before the quote
to make it point the right way. Then later I delete the yen character.
Here's a selection from where I altered the macro:
Selection.TypeText Text:=Chr(147)
Selection.InsertCrossReference ReferenceType:="Heading",
ReferenceKind:= _
wdContentText, ReferenceItem:=CStr(i), InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" "
'Selection.TypeText Text:=" on page "
Selection.TypeText Text:=Chr(165) & Chr(148) & " on page "
Selection.InsertCrossReference ReferenceType:="Heading",
ReferenceKind:= _
wdPageNumber, ReferenceItem:=CStr(i), InsertAsHyperlink:=True
I guess the trouble starts when I update my apostrophes to change them
all from straight to curly. Doing so always reverses the direction of
that closing quotation mark.
I wish there was a way to append the line Selection.TypeText
Text:=Chr(148) into the section where it inserts the reference. It just
needs something before the quotation mark to get it going the right
way.
I later delete the insertion of the yen character with this macro (run
after the straight-to-curly update):
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "¥"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
It works, but I feel stupid running it.
(I didn't realize that pressing alt+0165 inserted characters in the
Find field of the Find and Replace dialog box.)
Does anyone have a better solution than this yen character insertion?
|