View Single Post
  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Wildcard "special" searches

Great! Thanks! I'll try it shortly.

(I don't suppose you can handle XML? The Bibliography Tool has some
pretty annoying mistakes in it, and using Yves Dhondt's page I've been
able to correct only one of them.)

On Jul 27, 8:57*am, Venky62
T wrote:
Okay. Here is the modified code. This macro can be assigned to any
shortcut key combination and used. Place the cursor anywhere before the
first footnote reference you want to transpose and hit the shortcut
keys. It will transpose the footnote reference. Hit the shortcut key
again and it will transpose the next footnote reference in your text.
And so on. It will change only one footnote at a time.

As suggested by you, this macro does not cut and paste the footnote
reference but cuts and pastes the first character after the reference
which is not a space. So it doesn't matter if the character is a "." or
"," or anything else. This macro will work even if there are spaces
between the footnote reference and the next character. If there are
extra spaces, they will moved beyond the footnote reference.

Sub TransposeFootnote2()

'declare variables
Dim intpos1, intpos2 As Integer

'search for footnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find

Text = "^f"
Replacement.Text = ""
Forward = True
Wrap = wdFindStop
MatchWildcards = False

End With

Selection.Find.Execute

If Selection.Find.Found = True Then

'assign the character position of selection to variable
intpos1 = Selection.Characters.Last. _
Information(wdFirstCharacterColumnNumber)

'search for any character except space
Selection.Collapse wdCollapseEnd
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find

Text = "[!"" ""]"
Replacement.Text = ""
Forward = True
Wrap = wdFindStop
MatchWildcards = True

End With

Selection.Find.Execute

'assign selected character's position to variable
intpos2 = Selection.Characters.Last. _
Information(wdFirstCharacterColumnNumber)

'transpose footnote
With Selection

'cuts the character next to footnote and pastes it before
the footnote reference.
'This will work even if there are spaces between footnote
reference mark and the next character
Cut
Collapse
MoveLeft Unit:=wdCharacter, Count:=intpos2 - intpos1
PasteAndFormat wdFormatOriginalFormatting
'move curson beyond the transposed footnote so as to search
for the next
MoveRight Unit:=wdCharacter, Count:=2

End With
Else
Exit Sub
End If

End Sub

Peter T. Daniels;492901 Wrote:





Why would I want to cut and paste the footnote, instead of cutting and
pasting the punctuation mark? (If Track Changes were on, it would
create tremendous havoc in the notes, because it gives a number to
both a deleted and an inserted copy of the same note.)


And it would be better to do them individually rather than all at
once.


The reason for the wild card is so that I can put the cursor between
the note and the following period, comma, etc., and press Ctrl-T (the
shortcut I assigned to the Transpose macro). Is there some other way
to accomplish that?


If it has to be a separate macro, I can give it Ctrl-Shift-T. If that
comes assigned to something, it's not something I use! (Just as I
assigned Ctrl-\ to Accept Change and Ctrl-Shift-\ to Reject Change --
can't imagine why any of these three shortcuts aren't built in.)


(Normally a space would not intervene, so "next character" is fine.)


Thank you for your efforts!