Reply
 
Thread Tools Display Modes
  #1   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

(Word2007)

My authors are European, so they love to put their periods and commas
after their footnote references, but that's not how we Americans do
it. I'm getting tired of manually moving the punctuation around (and
the Transpose macro results in a superscript period before the
footnote reference, which isn't an improvement).

Word tells me that I cannot use both ^f and Wildcards in a
(Find-)Replace, so how can I automate this procedure? (Is it possible
to modify the Transpose macro to not affect the Superscript status of
the characters involved, since it's unlikely in the extreme that a
typo would involve superscripting!)

(Here's the text of the macro that was provided here years ago; it was
modified from the original because it was taking longer and longer to
work as a file got bigger, so a checking operation was removed.)

Sub Transpose()
Dim oRng As Range
Dim sText As String
Dim Msg1 As String
Dim Msg2 As String
Dim Msg3 As String
Dim MsgTitle As String
Msg1 = "You must place the cursor between " & _
"the 2 characters to be transposed!"
Msg2 = "There are no characters to transpose?"
Msg3 = "There is no document open!"
MsgTitle = "Transpose Characters"
On Error GoTo ErrorHandler
Set oRng = Selection.Range
Select Case Len(oRng)
Case Is = 0
If oRng.Start = oRng.Paragraphs(1).Range.Start Then
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End If
If oRng.End = oRng.Paragraphs(1).Range.End - 1 Then
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End If
With oRng
.Start = .Start - 1
.End = .End + 1
.Select
sText = .Text
End With
Case Is = 1
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
Case Is = 2
sText = Selection.Range.Text
Case Else
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End Select
With Selection
If .Range.Characters(1).Case = 1 _
And .Range.Characters(2).Case = 0 Then
.TypeText UCase(Mid(sText, 2, 1)) & _
LCase(Mid(sText, 1, 1))
Else
.TypeText Mid(sText, 2, 1) & _
Mid(sText, 1, 1)
End If
.MoveLeft wdCharacter
End With
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub
  #2   Report Post  
Venky62 Venky62 is offline
Junior Member
 
Posts: 19
Default

I modified the code slightly. This should solve your problem.

Sub Transpose()
Dim oRng As Range
Dim sText As String
Dim Msg1 As String
Dim Msg2 As String
Dim Msg3 As String
Dim MsgTitle As String
Msg1 = "You must place the cursor between " & _
"the 2 characters to be transposed!"
Msg2 = "There are no characters to transpose?"
Msg3 = "There is no document open!"
MsgTitle = "Transpose Characters"
On Error GoTo ErrorHandler
Set oRng = Selection.Range
Select Case Len(oRng)
Case Is = 0
If oRng.Start = oRng.Paragraphs(1).Range.Start Then
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End If
If oRng.End = oRng.Paragraphs(1).Range.End - 1 Then
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End If
With oRng
.Start = .Start - 1
.End = .End + 1
.Select
sText = .Text
End With
Case Is = 1
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
Case Is = 2
sText = Selection.Range.Text
Case Else
MsgBox Msg1, vbCritical, MsgTitle
Exit Sub
End Select
With Selection
If .Range.Characters(1).Case = 1 _
And .Range.Characters(2).Case = 0 Then
.TypeText UCase(Mid(sText, 2, 1)) & _
LCase(Mid(sText, 1, 1))

ElseIf .Range.Characters(1).Font.Superscript = True _
And .Range.Characters(2).Font.Superscript = False Then

.TypeText UCase(Mid(sText, 2, 1)) & _
LCase(Mid(sText, 1, 1))
Selection.MoveStart Unit:=wdCharacter, Count:=-2
Selection.Characters(1).Font.Superscript = False
Selection.Characters(2).Font.Superscript = True

Else
.TypeText Mid(sText, 2, 1) & _
Mid(sText, 1, 1)
End If
.MoveLeft wdCharacter
End With
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub


Quote:
Originally Posted by Peter T. Daniels View Post
(Word2007)

My authors are European, so they love to put their periods and commas
after their footnote references, but that's not how we Americans do
it. I'm getting tired of manually moving the punctuation around (and
the Transpose macro results in a superscript period before the
footnote reference, which isn't an improvement).

Word tells me that I cannot use both ^f and Wildcards in a
(Find-)Replace, so how can I automate this procedure? (Is it possible
to modify the Transpose macro to not affect the Superscript status of
the characters involved, since it's unlikely in the extreme that a
typo would involve superscripting!)
  #3   Report Post  
Venky62 Venky62 is offline
Junior Member
 
Posts: 19
Default

Where are you placing the cursor ? Please try the macro with the cursor anywhere on the line where the footnote reference is located but before the footnote reference. It should work.

Please let me know if it doesn't. If not, I will code for placing the cursor between the footnote reference and the next character. If you can get this macro to work, it should be even more convenient for you.

Quote:
Originally Posted by Venky62 View Post
  #4   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

On Jul 28, 11:19*pm, Venky62
T wrote:
Where are you placing the cursor ? Please try the macro with the cursor
anywhere on the line where the footnote reference is located but before
the footnote reference. It should work.


I placed the cursor a few characters before the footnote reference, on
the same line.

I just tried it again, and the Visual Basic window opened, with the
line "Cut" highlighted and a little box reading "Compile error: Sub or
Function not defined."

Please let me know if it doesn't. If not, I will code for placing the
cursor between the footnote reference and the next character. If you can
get this macro to work, it should be even more convenient for you.


Indeed.
  #5   Report Post  
Venky62 Venky62 is offline
Junior Member
 
Posts: 19
Default

I can't figure it out. Maybe something was left out while copying my code? Is there a period before the cut statement? Like ".cut" ?

Could you upload your document so that I could see where the error is creeping in?

Quote:
Originally Posted by Peter T. Daniels View Post
On Jul 28, 11:19*pm, Venky62
wrote:
Where are you placing the cursor ? Please try the macro with the cursor
anywhere on the line where the footnote reference is located but before
the footnote reference. It should work.


I placed the cursor a few characters before the footnote reference, on
the same line.

I just tried it again, and the Visual Basic window opened, with the
line "Cut" highlighted and a little box reading "Compile error: Sub or
Function not defined."

Please let me know if it doesn't. If not, I will code for placing the
cursor between the footnote reference and the next character. If you can
get this macro to work, it should be even more convenient for you.


Indeed.


  #6   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

On Jul 29, 10:48*am, Venky62
T wrote:
I can't figure it out. Maybe something was left out while copying my
code? Is there a period before the cut statement? Like ".cut" ?


Nope. It's directly below two lines in green.

Could you upload your document so that I could see where the error is
creeping in?


You want me to upload my normal.dotm template somewhere? Where?

I installed the macro simply by copying your text from the newsgroup
to the clipboard, then to a Notepad file; then copied it from the
Notepad file to the template (following Greg Mayor's instructions,
which have worked all the times people have posted useful macros here
before).

Peter T. Daniels;492930 Wrote:





On Jul 28, 11:19*pm, Venky62
wrote:-
Where are you placing the cursor ? Please try the macro with the
cursor
anywhere on the line where the footnote reference is located but
before
the footnote reference. It should work.-


I placed the cursor a few characters before the footnote reference, on
the same line.


I just tried it again, and the Visual Basic window opened, with the
line "Cut" highlighted and a little box reading "Compile error: Sub or
Function not defined."
-
Please let me know if it doesn't. If not, I will code for placing the
cursor between the footnote reference and the next character. If you
can
get this macro to work, it should be even more convenient for you.-


Indeed.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logical OR in Word wildcard searches wildetudor Microsoft Word Help 2 March 17th 09 02:13 AM
In "Paste Special", Can I set "Unformatted Text" as the first choi ATMYTV Microsoft Word Help 1 April 24th 08 06:07 AM
How to default to "Unformatted Text" in "Paste Special" in Word 20 Lucky Green Microsoft Word Help 3 October 4th 06 06:52 AM
Wildcard file searches PA New Users 1 July 12th 06 01:09 PM
specific searches in word documents, ie "Trust C" cware Microsoft Word Help 2 March 23rd 06 03:39 PM


All times are GMT +1. The time now is 05:11 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"