View Single Post
  #9   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

I'm afraid it doesn't work ... I put an icon for it on my QAT and when I clicked it, it immediately opened the macro listing with the line "Cut" highlighted, apparently claiming that it didn't tell it what to Cut.

(I had to use the icon because I assigned Crtl-Shift-T to the macro but when I tried that in my text, it seemed to think I wanted to apply a digital signature, or something like that.)

(Any possibility that, in the fixing, you could make it work not by searching for the next footnote, but simply by placing the cursor between the footnote reference and the following character, the things that need to be transposed?)

Thank you!

[I have just been forced back into New Google Groups again, and it is now insisting on adding a blank line after every quoted line.]

On Friday, July 27, 2012 8:57:38 AM UTC-4, Venky62 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!














--

Venky62