SendKeys problem with wdDialogInsertCrossReference


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Word Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Word Forum Members, post questions in this forum if they are related to using Microsoft Word, this includes Document Properties, VBA Programming & Functionality etc.

New Reply
Thread Tools Rate Thread Display Modes
  #1  
Unread 16th November 2009, 06:17
Brian Murphy's Avatar
Brian Murphy
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default SendKeys problem with wdDialogInsertCrossReference
     Word: VBA   


------ Register to get rid of these "In Post" ads! ------

Category: Word: VBA   

I have some code that works fine in Word 2003 for displaying notorious
Insert Cross Reference dialog. This is to display the dialog so as to
insert a cross reference to a Figure caption.
With Dialogs(wdDialogInsertCrossReference)
SendKeys "%t{home}ff"
SendKeys "{enter}"
SendKeys "%r"
SendKeys "{down}"
SendKeys "{enter}"
SendKeys "%w" 'move to list of references
rtn = .Display
End With

This code does not work in Word 2007. In Word 2003 the "ff" moves the
selection first to Footnote, and then to Figure. But in Word 2007 the
second "f" does not get done, and the selection is stuck on Footnote.
I have spent hours trying find something that works, but nothing does.

Does anyone know how to get this to work?

Thanks,

Brian Murphy

The Code Cage Advertisment
Advertisement
  #2  
Unread 16th November 2009, 08:09
Doug Robbins - Word MVP's Avatar
Doug Robbins - Word MVP
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


Try

With Dialogs(wdDialogInsertCrossReference)
SendKeys "%t"
SendKeys "fef"
SendKeys "{enter}"
SendKeys "%r"
SendKeys "{down}"
SendKeys "{enter}"
SendKeys "%w" 'move to list of references
rtn = .Display
End With

I am not sure what would be considered more notoriously unreliable, the
Cross Reference Dialog (which I consider does behave itself better in 2007
than it did in previous versions) or SendKeys.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
"Brian Murphy" <bmurphy@xlrotor.com> wrote in message
news:ae3fc50f-f37c-43c7-b05a-6cea0683c8e9@v25g2000yqk.googlegroups.com...
>I have some code that works fine in Word 2003 for displaying notorious
> Insert Cross Reference dialog. This is to display the dialog so as to
> insert a cross reference to a Figure caption.
> With Dialogs(wdDialogInsertCrossReference)
> SendKeys "%t{home}ff"
> SendKeys "{enter}"
> SendKeys "%r"
> SendKeys "{down}"
> SendKeys "{enter}"
> SendKeys "%w" 'move to list of references
> rtn = .Display
> End With
>
> This code does not work in Word 2007. In Word 2003 the "ff" moves the
> selection first to Footnote, and then to Figure. But in Word 2007 the
> second "f" does not get done, and the selection is stuck on Footnote.
> I have spent hours trying find something that works, but nothing does.
>
> Does anyone know how to get this to work?
>
> Thanks,
>
> Brian Murphy



  #3  
Unread 16th November 2009, 16:32
Brian Murphy's Avatar
Brian Murphy
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


Thanks for the suggestion, Doug.

I gave it a try, but the problem still remains. The selection is
still stuck on Footnote.

Did you try it yourself and it worked?
If so, what Application.Build of Word2007 are you using?

Brian

On Nov 16, 1:01 am, "Doug Robbins - Word MVP"
<d...@REMOVECAPSmvps.org> wrote:
> Try
>
> With Dialogs(wdDialogInsertCrossReference)
> SendKeys "%t"
> SendKeys "fef"
> SendKeys "{enter}"
> SendKeys "%r"
> SendKeys "{down}"
> SendKeys "{enter}"
> SendKeys "%w" 'move to list of references
> rtn = .Display
> End With
>
> I am not sure what would be considered more notoriously unreliable, the
> Cross Reference Dialog (which I consider does behave itself better in 2007
> than it did in previous versions) or SendKeys.
>
> --
> Hope this helps,
>
> Doug Robbins - Word MVP
>
> Please reply only to the newsgroups unless you wish to obtain my services on
> a paid professional basis."Brian Murphy" <bmur...@xlrotor.com> wrote in message
>
> news:ae3fc50f-f37c-43c7-b05a-6cea0683c8e9@v25g2000yqk.googlegroups.com...
>
> >I have some code that works fine in Word 2003 for displaying notorious
> > Insert Cross Reference dialog. This is to display the dialog so as to
> > insert a cross reference to a Figure caption.
> > With Dialogs(wdDialogInsertCrossReference)
> > SendKeys "%t{home}ff"
> > SendKeys "{enter}"
> > SendKeys "%r"
> > SendKeys "{down}"
> > SendKeys "{enter}"
> > SendKeys "%w" 'move to list of references
> > rtn = .Display
> > End With

>
> > This code does not work in Word 2007. In Word 2003 the "ff" moves the
> > selection first to Footnote, and then to Figure. But in Word 2007 the
> > second "f" does not get done, and the selection is stuck on Footnote.
> > I have spent hours trying find something that works, but nothing does.

>
> > Does anyone know how to get this to work?

>
> > Thanks,

>
> > Brian Murphy



The Code Cage Advertisment
Advertisement
  #4  
Unread 16th November 2009, 20:55
Doug Robbins - Word MVP's Avatar
Doug Robbins - Word MVP
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


Yes, it did work here with Word 2007 (12.0.6514.5000) SP2 MSO
(12.0.6425.1000)

--
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, originally posted via msnews.microsoft.com

"Brian Murphy" <bmurphy@xlrotor.com> wrote in message
news:a5435dd9-2856-4beb-b864-82c986a7623b@l2g2000yqd.googlegroups.com...
> Thanks for the suggestion, Doug.
>
> I gave it a try, but the problem still remains. The selection is
> still stuck on Footnote.
>
> Did you try it yourself and it worked?
> If so, what Application.Build of Word2007 are you using?
>
> Brian
>
> On Nov 16, 1:01 am, "Doug Robbins - Word MVP"
> <d...@REMOVECAPSmvps.org> wrote:
>> Try
>>
>> With Dialogs(wdDialogInsertCrossReference)
>> SendKeys "%t"
>> SendKeys "fef"
>> SendKeys "{enter}"
>> SendKeys "%r"
>> SendKeys "{down}"
>> SendKeys "{enter}"
>> SendKeys "%w" 'move to list of references
>> rtn = .Display
>> End With
>>
>> I am not sure what would be considered more notoriously unreliable, the
>> Cross Reference Dialog (which I consider does behave itself better in
>> 2007
>> than it did in previous versions) or SendKeys.
>>
>> --
>> Hope this helps,
>>
>> Doug Robbins - Word MVP
>>
>> Please reply only to the newsgroups unless you wish to obtain my services
>> on
>> a paid professional basis."Brian Murphy" <bmur...@xlrotor.com> wrote in
>> message
>>
>> news:ae3fc50f-f37c-43c7-b05a-6cea0683c8e9@v25g2000yqk.googlegroups.com...
>>
>> >I have some code that works fine in Word 2003 for displaying notorious
>> > Insert Cross Reference dialog. This is to display the dialog so as to
>> > insert a cross reference to a Figure caption.
>> > With Dialogs(wdDialogInsertCrossReference)
>> > SendKeys "%t{home}ff"
>> > SendKeys "{enter}"
>> > SendKeys "%r"
>> > SendKeys "{down}"
>> > SendKeys "{enter}"
>> > SendKeys "%w" 'move to list of references
>> > rtn = .Display
>> > End With

>>
>> > This code does not work in Word 2007. In Word 2003 the "ff" moves the
>> > selection first to Footnote, and then to Figure. But in Word 2007 the
>> > second "f" does not get done, and the selection is stuck on Footnote.
>> > I have spent hours trying find something that works, but nothing does.

>>
>> > Does anyone know how to get this to work?

>>
>> > Thanks,

>>
>> > Brian Murphy

>


  #5  
Unread 17th November 2009, 05:12
Brian Murphy's Avatar
Brian Murphy
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


Well darn!
Do you have both Footnote and Figure in your list of available
reference types?

I have MSO SP2 from the following download
http://www.microsoft.com/downloads/d...displaylang=en
Word tells me I've got
Word 2007 (12.0.6425.1000) SP2 MSO (12.0.6425.1000)

How can I get build 6514 of Word? I don't really expect it to make
any difference, but you never know.

When I manually do Insert/Cross Reference, I have to type "fef" slowly
to move the selection from Footnote, to Equation, to Figure. If I
type the "fef" quickly, the selection stays on Footnote.

Something wierd is going on. I've tried it on three different
computers with the same result. Grrrr!

Brian

  #6  
Unread 17th November 2009, 07:37
Doug Robbins - Word MVP's Avatar
Doug Robbins - Word MVP
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


As I had mentioned, my experience with Word 2007 is that the Insert Cross
Reference dialog behaves better than it did in previous versions where it
annoyed the hell out of me when I left the dialog open and wanted to insert
another cross reference, the focus would return to the top of the list.

As an alternative to using that dialog, you might consider creating a
userform that contained a listbox to display the type of reference items and
code to insert a cross reference based on the item selected from the
listbox.

Such a listbox can be populated using the following code in the initialize
statement of the userform

Dim afield As Field
Dim caplist As String
Dim i As Long
caplist = ""
For Each afield In ActiveDocument.Fields
If afield.Type = wdFieldSequence And InStr(afield.Code, "Figure") > 0
Then
If caplist = "" Then
caplist = "Figure " & afield.Result
Else
caplist = caplist & "|Figure " & afield.Result
End If
End If
Next afield
lstCap.List = Split(caplist, "|")


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
"Brian Murphy" <bmurphy@xlrotor.com> wrote in message
news:d290f3a2-5525-49a6-925c-51b9fefd3bad@x31g2000yqx.googlegroups.com...
> Well darn!
> Do you have both Footnote and Figure in your list of available
> reference types?
>
> I have MSO SP2 from the following download
> http://www.microsoft.com/downloads/d...displaylang=en
> Word tells me I've got
> Word 2007 (12.0.6425.1000) SP2 MSO (12.0.6425.1000)
>
> How can I get build 6514 of Word? I don't really expect it to make
> any difference, but you never know.
>
> When I manually do Insert/Cross Reference, I have to type "fef" slowly
> to move the selection from Footnote, to Equation, to Figure. If I
> type the "fef" quickly, the selection stays on Footnote.
>
> Something wierd is going on. I've tried it on three different
> computers with the same result. Grrrr!
>
> Brian



The Code Cage Advertisment
Advertisement
  #7  
Unread 17th November 2009, 12:23
Jonathan West's Avatar
Jonathan West
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


Hi Brian

It may be that the problem is that you are using Word 2007 under Windows
Vista. Sendkeys is broken under Vista, which as far as I can tell appears to
be a deliberate act on the part of Microsoft. Goodness only knows why.

You might want to try using Karl Peterson's SendKeys replacement, which is
available here.
http://vb.mvps.org/samples/SendInput/

It is a module that you can drop into your VBA project and have it work
exactly as Sendkeys used to.


--
Regards
Jonathan West





"Brian Murphy" <bmurphy@xlrotor.com> wrote in message
news:d290f3a2-5525-49a6-925c-51b9fefd3bad@x31g2000yqx.googlegroups.com...
> Well darn!
> Do you have both Footnote and Figure in your list of available
> reference types?
>
> I have MSO SP2 from the following download
> http://www.microsoft.com/downloads/d...displaylang=en
> Word tells me I've got
> Word 2007 (12.0.6425.1000) SP2 MSO (12.0.6425.1000)
>
> How can I get build 6514 of Word? I don't really expect it to make
> any difference, but you never know.
>
> When I manually do Insert/Cross Reference, I have to type "fef" slowly
> to move the selection from Footnote, to Equation, to Figure. If I
> type the "fef" quickly, the selection stays on Footnote.
>
> Something wierd is going on. I've tried it on three different
> computers with the same result. Grrrr!
>
> Brian



  #8  
Unread 18th November 2009, 16:21
Brian Murphy's Avatar
Brian Murphy
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


Thank you Doug and Jonathan for the suggestions.

I've been trying really hard to avoid resorting to a custom userform,
but it's just about come to that.

I've been testing in both XP and Vista, and I haven't noticed any
difference in behavior for my particular macros.

I'm sure you know this, but I'm trying to display the Insert Cross
Reference dialog with my choice of Reference Type pre-selected. So
that the user can select the item to be cross-referenced.

I think I'll give SendInput a try, but I'm not too optimistic. Then
it'll have to be a userform.

Have either of you tried Word 2007 in Windows 7? I have not. More
fun in the sun.

Brian

If you want to try or look at my code yourself, download these
files.
http://www.rotordynamics.org/public/...umentation.pdf
www.rotordynamics.org/public/murf_macros.dot
I create lots of engineering reports and technical papers, and these
macros help me a lot.
If all you want to do is look at the code, put murf_macros.dot on the
desktop and use File/Open from inside Word to open it.

  #9  
Unread 18th November 2009, 22:11
Doug Robbins - Word MVP's Avatar
Doug Robbins - Word MVP
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: SendKeys problem with wdDialogInsertCrossReference

------ Register to get rid of these "In Post" ads! ------


It's no more fun (nor less) in Windows 7 than it was in Vista of XP

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
"Brian Murphy" <bmurphy@xlrotor.com> wrote in message
news:75b15c67-870e-43a0-85a5-cb3812749bc1@j4g2000yqe.googlegroups.com...
> Thank you Doug and Jonathan for the suggestions.
>
> I've been trying really hard to avoid resorting to a custom userform,
> but it's just about come to that.
>
> I've been testing in both XP and Vista, and I haven't noticed any
> difference in behavior for my particular macros.
>
> I'm sure you know this, but I'm trying to display the Insert Cross
> Reference dialog with my choice of Reference Type pre-selected. So
> that the user can select the item to be cross-referenced.
>
> I think I'll give SendInput a try, but I'm not too optimistic. Then
> it'll have to be a userform.
>
> Have either of you tried Word 2007 in Windows 7? I have not. More
> fun in the sun.
>
> Brian
>
> If you want to try or look at my code yourself, download these
> files.
> http://www.rotordynamics.org/public/...umentation.pdf
> www.rotordynamics.org/public/murf_macros.dot
> I create lots of engineering reports and technical papers, and these
> macros help me a lot.
> If all you want to do is look at the code, put murf_macros.dot on the
> desktop and use File/Open from inside Word to open it.



The Code Cage Advertisment
Advertisement
New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
problem, sendkeys

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 22:37.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University