Supress "Opening this document with run the following SQL command"

C

Chris K

I know this must be asked 1000 times per day - so hopefully there is a
solution

Can I stop word telling me what it's told me a million times before? namely
"Opening this document with run the following SQL command"

It's causing havoc - I am trying to open a document from an Access Form

I can not answer the prompt because it is popping up underneath the modal
form - the form will not budge because it's waiting for the prompt to be
answered

Only solution is CTRL+ALT+DEL
 
C

Chris K

I'm not in a position to modify registry on company computers but thanks

So the short answer is that Access cannot be used to open an MS Word Mail
merge

P.S. Social Answers forums can not replace the current newsgroups
currently - just took a peek and the existing forums barely scratch the
surface of office apps (Access is hardly mentioned)

Maybe in next 5 years



Doug Robbins - Word MVP said:
See the following Knowledge Base article:

"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

Note these newsgroups are no longer hosted by Microsoft and are now
orphans
in the wilderness.

As a replacement for the newsgroups, Microsoft has created forums that can
be accessed at:

http://social.answers.microsoft.com/Forums/en-US/category/officeword


--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

Chris K said:
I know this must be asked 1000 times per day - so hopefully there is a
solution

Can I stop word telling me what it's told me a million times before?
namely "Opening this document with run the following SQL command"

It's causing havoc - I am trying to open a document from an Access Form

I can not answer the prompt because it is popping up underneath the modal
form - the form will not budge because it's waiting for the prompt to be
answered

Only solution is CTRL+ALT+DEL
 
G

Graham Mayor

If you don't make the registry change, you merely have to acknowledge the
prompt.

There's a macro at http://www.gmayor.com/word_vba_examples.htm which will
toggle the prompt on/off, but as it writes to the registry, I don't suppose
your company IT Nazis will approve of that either? Software does however
write to the registry all the time.

Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Chris K said:
I'm not in a position to modify registry on company computers but thanks

So the short answer is that Access cannot be used to open an MS Word Mail
merge

P.S. Social Answers forums can not replace the current newsgroups
currently - just took a peek and the existing forums barely scratch the
surface of office apps (Access is hardly mentioned)

Maybe in next 5 years



Doug Robbins - Word MVP said:
See the following Knowledge Base article:

"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

Note these newsgroups are no longer hosted by Microsoft and are now
orphans
in the wilderness.

As a replacement for the newsgroups, Microsoft has created forums that
can
be accessed at:

http://social.answers.microsoft.com/Forums/en-US/category/officeword


--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

Chris K said:
I know this must be asked 1000 times per day - so hopefully there is a
solution

Can I stop word telling me what it's told me a million times before?
namely "Opening this document with run the following SQL command"

It's causing havoc - I am trying to open a document from an Access Form

I can not answer the prompt because it is popping up underneath the
modal form - the form will not budge because it's waiting for the prompt
to be answered

Only solution is CTRL+ALT+DEL
 
W

Walter Briscoe

In message <[email protected]> of Sat, 21 Aug 2010
16:10:40 in microsoft.public.word.mailmerge.fields, Graham Mayor
If you don't make the registry change, you merely have to acknowledge the
prompt.

There's a macro at http://www.gmayor.com/word_vba_examples.htm which will
toggle the prompt on/off, but as it writes to the registry, I don't suppose
your company IT Nazis will approve of that either? Software does however
write to the registry all the time.

Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

I hope the forums are not the future, but fear I will be wrong.
On reading Doug Robbins recommendation, I followed the link.
I don't think he model does not give me what I have traditionally had
with newsgroups and I don't like what I do get. e.g.
1) one line per thread subject.
2) threading so I can tell the relationship between posts.
This thread is not a good example, as it consists of 4 messages:
a) Chris K posted the first message;
b) Doub Robbins replied to message a)
c) Chris K replied to message b)
d) Graham replied to message c).
3) I normally open a window in which threads containing new messages
appear first and others in which I retain an interest are then shown.
I can mark all messages as read, mark messages as interesting, and/or to
be retained. I can zap old messages when I choose.
4) I can batch download messages for future attention. I don't need an
Internet connection except when sending messages or grabbing them.
5) Cross-posting is supported. Used well, it can be helpful.
5) I can use Google groups to search a vast history of messages.
6) Group, and message creation is largely anarchic.

There are probably virtues in the forums. All I can see to date is
1) They are promoted by Microsoft.
2) Their Traffic is likely to be heavier than in traditional newsgroups
now that they exist.
3) Less spam - I assume this is true.
 
C

Chris K

Graham Mayor said:
If you don't make the registry change, you merely have to acknowledge the
prompt.

as mentioned, the prompt appears underneath the calling form, the form wont
budge (and Word wont open) until the prompt is answered - chicken + egg =
CTRL ALT Del

There's a macro at http://www.gmayor.com/word_vba_examples.htm which will
toggle the prompt on/off, but as it writes to the registry, I don't
suppose your company IT Nazis will approve of that either? Software does
however write to the registry all the time.

Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Chris K said:
I'm not in a position to modify registry on company computers but thanks

So the short answer is that Access cannot be used to open an MS Word Mail
merge

P.S. Social Answers forums can not replace the current newsgroups
currently - just took a peek and the existing forums barely scratch the
surface of office apps (Access is hardly mentioned)

Maybe in next 5 years



Doug Robbins - Word MVP said:
See the following Knowledge Base article:

"Opening This Will Run the Following SQL Command" Message When You Open
a Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

Note these newsgroups are no longer hosted by Microsoft and are now
orphans
in the wilderness.

As a replacement for the newsgroups, Microsoft has created forums that
can
be accessed at:

http://social.answers.microsoft.com/Forums/en-US/category/officeword


--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

I know this must be asked 1000 times per day - so hopefully there is a
solution

Can I stop word telling me what it's told me a million times before?
namely "Opening this document with run the following SQL command"

It's causing havoc - I am trying to open a document from an Access Form

I can not answer the prompt because it is popping up underneath the
modal form - the form will not budge because it's waiting for the
prompt to be answered

Only solution is CTRL+ALT+DEL
 
I

Ian

Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

There will always be those of us who prefer to use a newsreader and
access info via Usenet.

Hope all are well.
Ian
 
P

Peter T. Daniels

Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007 on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?

[followup set]
 
D

Doug Robbins - Word MVP

If you use the Community Bridge to access the newsgroups via an NNTP
newsreader, the experience is much the same as that to which you are
accustomed.
 
G

Graham Mayor

I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so cannot
check it out. If you post the code, someone else may be able to check it.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007 on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?

[followup set]
 
P

Peter T. Daniels

Here's the code:

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
If ActiveDocument.Characters.Count > 2 Then
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
Else
MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub

I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so cannot
check it out. If you post the code, someone else may be able to check it.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Agreed, the forums are poor, but they are the future ... unless everyone
come back here ;)

Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007  on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?

[followup set]
 
J

John W. Vinson

There are probably virtues in the forums. All I can see to date is
1) They are promoted by Microsoft.
2) Their Traffic is likely to be heavier than in traditional newsgroups
now that they exist.

Much lighter, at least so far. MS is not prominently publicizing these groups,
and they seem to be harder to find than the newsgroups.
3) Less spam - I assume this is true.

That at least appears to be the case - there are moderators who do remove
blatant spam promptly. The registration requirement (even if it's just the
need to use a msn email account) probably does the most to keep spam down.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
S

Suzanne S. Barnhill

You can download the Answers Bridge (provided by MS even though it does
claim to be "not a Microsoft developed application") from
https://connect.microsoft.com/MicrosoftForums?wa=wsignin1.0 and the
Community Bridge (written by an MVP) from
http://communitybridge.codeplex.com/.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Doug Robbins - Word MVP said:
If you use the Community Bridge to access the newsgroups via an NNTP
newsreader, the experience is much the same as that to which you are
accustomed.

--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

Walter Briscoe said:
In message <[email protected]> of Sat, 21 Aug 2010
16:10:40 in microsoft.public.word.mailmerge.fields, Graham Mayor


I hope the forums are not the future, but fear I will be wrong.
On reading Doug Robbins recommendation, I followed the link.
I don't think he model does not give me what I have traditionally had
with newsgroups and I don't like what I do get. e.g.
1) one line per thread subject.
2) threading so I can tell the relationship between posts.
This thread is not a good example, as it consists of 4 messages:
a) Chris K posted the first message;
b) Doub Robbins replied to message a)
c) Chris K replied to message b)
d) Graham replied to message c).
3) I normally open a window in which threads containing new messages
appear first and others in which I retain an interest are then shown.
I can mark all messages as read, mark messages as interesting, and/or to
be retained. I can zap old messages when I choose.
4) I can batch download messages for future attention. I don't need an
Internet connection except when sending messages or grabbing them.
5) Cross-posting is supported. Used well, it can be helpful.
5) I can use Google groups to search a vast history of messages.
6) Group, and message creation is largely anarchic.

There are probably virtues in the forums. All I can see to date is
1) They are promoted by Microsoft.
2) Their Traffic is likely to be heavier than in traditional newsgroups
now that they exist.
3) Less spam - I assume this is true.
 
P

Peter T. Daniels

Turns out it works at normal speed in a small (10-p.) document; the
one it's slow in is 180 pp. But since the pair of characters it works
on is the two characters on either side of the cursor (or two selected
characters), why would it need to search the entire file?

Here's the code:

SubTranspose()
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 totranspose?"
Msg3 = "There is no document open!"
MsgTitle = "TransposeCharacters"
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
    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
Else
    MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
    MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub

I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so cannot
check it out. If you post the code, someone else may be able to check it.
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007  on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?
[followup set]-
 
G

Graham Mayor

The delay is attributable to the character count used as part of the error
checking. You can remove that part of the error checking and it will respond
instantly - provided there are characters to transpose when you run it.


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

Turns out it works at normal speed in a small (10-p.) document; the
one it's slow in is 180 pp. But since the pair of characters it works
on is the two characters on either side of the cursor (or two selected
characters), why would it need to search the entire file?

Here's the code:

SubTranspose()
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 totranspose?"
Msg3 = "There is no document open!"
MsgTitle = "TransposeCharacters"
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
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
Else
MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub

I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so
cannot
check it out. If you post the code, someone else may be able to check
it.
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007 on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?
[followup set]-
 
P

Peter T. Daniels

It seems you deleted one line near the beginning and three lines near
the end. Can I also remove the lines containing or mentioning "Msg2"
at the top? Or would all the "Msg3" mentions have to be changed to
"Msg2"?

The delay is attributable to the character count used as part of the error
checking. You can remove that part of the error checking and it will respond
instantly - provided there are characters to transpose when you run it.

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

Turns out it works at normal speed in a small (10-p.) document; the
one it's slow in is 180 pp. But since the pair of characters it works
on is the two characters on either side of the cursor (or two selected
characters), why would it need to search the entire file?

Here's the code:
SubTranspose()
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 totranspose?"
Msg3 = "There is no document open!"
MsgTitle = "TransposeCharacters"
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
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
Else
MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub
I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so
cannot
check it out. If you post the code, someone else may be able to check
it.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
messageAgreed, the forums are poor, but they are the future ... unless
everyone
come back here ;)
Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007 on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?
[followup set]--
 
G

Graham Mayor

Yes you can remove the references to Msg2 as they are now redundant. You can
change the references to Msg3 to Msg2 if you wish, but it will work just the
same without.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


It seems you deleted one line near the beginning and three lines near
the end. Can I also remove the lines containing or mentioning "Msg2"
at the top? Or would all the "Msg3" mentions have to be changed to
"Msg2"?

The delay is attributable to the character count used as part of the error
checking. You can remove that part of the error checking and it will
respond
instantly - provided there are characters to transpose when you run it.

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

messageTurns out it works at normal speed in a small (10-p.) document; the
one it's slow in is 180 pp. But since the pair of characters it works
on is the two characters on either side of the cursor (or two selected
characters), why would it need to search the entire file?

Here's the code:
SubTranspose()
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 totranspose?"
Msg3 = "There is no document open!"
MsgTitle = "TransposeCharacters"
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
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
Else
MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub
I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so
cannot
check it out. If you post the code, someone else may be able to check
it.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
messageAgreed, the forums are poor, but they are the future ... unless
everyone
come back here ;)
Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007 on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?
[followup set]--
 
P

Peter T. Daniels

Ok -- thanks for the fix!

Yes you can remove the references to Msg2 as they are now redundant. You can
change the references to Msg3 to Msg2 if you wish, but it will work just the
same without.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

It seems you deleted one line near the beginning and three lines near
the end. Can I also remove the lines containing or mentioning "Msg2"
at the top? Or would all the "Msg3" mentions have to be changed to
"Msg2"?

The delay is attributable to the character count used as part of the error
checking. You can remove that part of the error checking and it will
respond
instantly - provided there are characters to transpose when you run it.
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
messageTurns out it works at normal speed in a small (10-p.) document; the
one it's slow in is 180 pp. But since the pair of characters it works
on is the two characters on either side of the cursor (or two selected
characters), why would it need to search the entire file?
Here's the code:
SubTranspose()
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 totranspose?"
Msg3 = "There is no document open!"
MsgTitle = "TransposeCharacters"
On Error GoTo ErrorHandler
If ActiveDocument.Characters.Count > 2 Then
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
Else
MsgBox Msg2, vbCritical, MsgTitle
End If
End
ErrorHandler:
If Err.Number = 4248 Then
MsgBox Msg3, vbCritical, MsgTitle
End If
End Sub
I have not been away :) With such low traffic, there have been few
opportunities to comment.
I don't remember the particular macro, but I don't use Windows 7 so
cannot
check it out. If you post the code, someone else may be able to check
it.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
messageAgreed, the forums are poor, but they are the future ... unless
everyone
come back here ;)
Glad to see you back here -- do you have any idea why the macro you
(I'm pretty sure) provided for transposing two letters works _nearly_
immediately on Word2007 on Vista, but very very slowly on Word2007 on
Windows 7, on the laptop whose CPU is otherwise rather faster than the
CPU in the old IBM ThinkCentre desktop?
[followup set]--- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top