SendKeys Will Not Work in Word 2007?
Hello,
I’m unsure how to update this macro for Word 2007 (Word/Window/VBA {version/build/Service Pack} specifics are below).
It worked fine in Word 2003 via preselecting the cross-reference dialog box (for Table, etc.) so one simply makes a final selection in the variable area.
I’ve been studying this “SendKey” issue, and the in the link http://vb.mvps.org/samples/SendInput/ it states “. . . in order to use the original SendKeys, you'll then have to prefix it with VBA.”
That sounds simple, but this newbie is confused.
Can somebody offer a solution (refitting this macro, or some OTHER VBA code) that will accomplish the same task?
Always appreciative of any help/insight.
Janet
Code:
Sub CrossReferenceTable ()
With Dialogs(wdDialogInsertCrossReference)
SendKeys "%t" '(Alt + T): To get to Reference {T}ype
SendKeys "+(table)" 'Holds down shift to enter ALL letters (in case there is a "tabl{a}" caption that could roll out first
SendKeys "{enter}" 'Enters parameters for the Reference Type
SendKeys "%r" '(Alt + R): To get to Insert {R}eference
SendKeys "{down 1}" 'Selects "Only Label & Number" from pre-defined drop-down list
SendKeys "{enter 1}" 'Enters parameters for Insert Reference
SendKeys "%h" '(Alt + h): To get to {H}yperlink
SendKeys "+{+}" '(Selects hyperlink checkbox -- even it if is already on -- does not toggle to and fro!
SendKeys "{enter 2}" ' Enters parameters for hyperlink, & brings you to the {variable} area which end-user selects
.Show
End With
End Sub
Version Specifics, etc.:
Word 2007:
· MS Office Word 2007 (12.0.6545.5000) SP2 MSO (12.0.6545.5004)
MS Windows
· MW Windows Version 5.1 (Build 2600.xpsp_sp3_gdr.101209-1647:Service Pack 3)
Visual Basic:
· VBA: Retail 6.5.1040
· MS Visual Basic 1987-2006
· Version 1040
· Forms3: 12.0.6415.100
MacroPod --Shouldn't SP2 & SP3 encompass SP1 fixes?
Thanks MacroPod,
Still confused.:dunno
I have SP2 (for Word) and SP3 (for Windows). Shouldn't that encompass the SP1 "fix"?
Please advise.
Janet
Works in Word 2010, not in Word 2007
Macropod:
Yep, it works in 2010; but unfortunately, I need to have it work within 2007.
I'm reading about numerous issues/quirks with SendKeys, and also with the Cross Reference Dialog Box.
Can anybody offer workaround sample?
Janet:doh:
Forgive me Macropod, but still confused . . .
The first link you provided refers to coding used in Word 2003 (not 2007). (I tried that macro anyway; and it did not work.)
The second link deals with inserting hyperlinks. (Not sure of Word version, but it doesn’t appear to involve cross-referencing anyway.)
The third link deals with inserting fields. (Not sure of Word version, but it doesn’t appear to involve cross-referencing anyway.)
I wished for some coding/workaround for Word 2007 using the insert cross-reference dialog box.
Any insight is appreciated. . .
I marked solved -- Thanks to all that replied!