How to Make Tabbing work from VBA
|
|
Thread rating:  |
Gary Hillerson - 30 Jan 2006 09:09 GMT I'm trying to figure out how to get tabbing from field-to-field to work in userForms I'm creating with VBA in Word 2004 on the Mac. Right now, the only way to change focus is to click the mouse in another textbox, even tho the tab key properly generates an Exit event.
As a simple test, I create a simple form with four controls: TextBox1, TextBox2, TextBox3, and a Cancel button that unloads the form.
I implement the _Enter and _Exit methods of each textbox to display a debug message, e.g. "TextBox2_Enter"
I type something into TextBox1 and then press the Tab key.
I get an Exit event on TextBox1, and an Enter event on Textbox2, as expected.
But then, I immediately see TextBox2_Exit, TextBox3_Enter, TextBox3_Exit, and TextBox1_Enter. The net result is that the same control (TextBox1) ends up with the focus.
Even manually calling the SetFocus method of one textbox from another's Exit method doesn't work; the focus always cycles back to the textbox in which I press the Tab key.
There must be some way to work around this tabbing problem, but I'm not finding it. Can anyone help?
thanks
Gary
John McGhie [MVP - Word and Word Macintosh] - 30 Jan 2006 13:08 GMT Gary:
No. We have never made it work. It's buggy, and they're not going to fix it (because VBA is deprecated).
Microsoft has made the decision to retire VBA because by design it cannot be adequately secured. Consequently, they are not going to put any further development effort into it.
On the PC, use VBA.NET (or C sharp...). VBA.NET is actually a different language that just happens to have similar syntax.
On the Mac, use AppleScript. Microsoft is putting all the available (limited) resources into fixing and enhancing AppleScript as its Mac Office scripting language. Alternatively, re-express your design in RealBasic, which ships as an optional install for Mac Office.
Cheers
On 30/1/06 8:09 PM, in article C00317CD.42B%garyh@hillysun.net, "Gary Hillerson" <garyh@hillysun.net> wrote:
> I'm trying to figure out how to get tabbing from field-to-field to work in > userForms I'm creating with VBA in Word 2004 on the Mac. Right now, the only [quoted text clipped - 26 lines] > > Gary
 Signature Please reply to the newsgroup to maintain the thread. Please do not email me unless I ask you to.
John McGhie <john@mcghie.name> Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer Sydney, Australia +61 (0) 4 1209 1410
Gary Hillerson - 30 Jan 2006 16:45 GMT John,
Thanks. I understand what you're saying, but I've got a giant piece of VBA code that isn't going to get rewritten in a hurry, especially with limited resources. And the code works in Office 2004, aside from a few very minor issues. The worst is this tabbing problem.
I understand that the built-in tabbing won't work properly, but I have to believe that I can "manually" make it work by catching the right event and handling it in some way. And it sure seems like someone must have figured out the correct sequence of events along the way.
If not, we'll just have to tell users to click instead of tabbing.
Thanks again, gary
>Gary: > >No. We have never made it work. It's buggy, and they're not going to fix >it (because VBA is deprecated). John McGhie [MVP - Word and Word Macintosh] - 30 Jan 2006 22:29 GMT Hi Gary:
On 31/1/06 3:45 AM, in article qggst19a764k5d415tm1oa9g9q7u875586@4ax.com,
> I understand that the built-in tabbing won't work properly, but I have > to believe that I can "manually" make it work by catching the right > event and handling it in some way. And it sure seems like someone must > have figured out the correct sequence of events along the way. > > If not, we'll just have to tell users to click instead of tabbing. Yep. You will :-) As far as I know, the reason it can't be made to work is that it's unstable. So whatever works today won't work the next time you open the solution.
I also told you something else. If you re-read what I said you may pick it up. If not, email me direct off-line.
Cheers
 Signature Please reply to the newsgroup to maintain the thread. Please do not email me unless I ask you to.
John McGhie <john@mcghie.name> Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer Sydney, Australia +61 (0) 4 1209 1410
Jeffrey Frankel - 04 Feb 2006 13:50 GMT Bummer. I just ran into the same problem Gary did. Several years ago I dove into VBA for Word for Macintosh 2001 or v.X (I forget which), wrote an application with a user form, and then, with a little bit of help, transferred it into Word 2000 for use at work. Recently, I dusted off the Mac version to demonstrate for my user group. Lo and behold, tabbing in the user form no longer works in the Mac version, and I was going nuts trying to figure out why until I found this thread.
Like Gary notes, tabbing works fine on the Windows side, now running Word 2003. The funny thing, unless my memory is way off, is that to the best of my recollection tabbing *used* to work in Word for Macintosh as well. Not that it matters any more, but am I mistaken on this point?
Jeff Frankel
On 1/30/06 5:29 PM, in article C004DE8E.2B549%john@mcghie.name, "John McGhie [MVP - Word and Word Macintosh]" <john@mcghie.name> wrote:
> Hi Gary: > [quoted text clipped - 15 lines] > > Cheers John McGhie [MVP - Word and Word Macintosh] - 07 Feb 2006 03:19 GMT Hi Jeffrey:
No, I think you're correct. As far as I recall, tab order worked in VBA up to Word 2001, and gotten broken in Word X. It may have been Word 2004.
The problem is: Now it's broken, and there's no budget to fix it. :-)
cheers
On 5/2/06 12:50 AM, in article C00A1B4C.A9C7%jfrankel@mac.com, "Jeffrey Frankel" <jfrankel@mac.com> wrote:
> Bummer. I just ran into the same problem Gary did. Several years ago I dove > into VBA for Word for Macintosh 2001 or v.X (I forget which), wrote an [quoted text clipped - 33 lines] >> >> Cheers
 Signature Please reply to the newsgroup to maintain the thread. Please do not email me unless I ask you to.
John McGhie <john@mcghie.name> Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer Sydney, Australia +61 (0) 4 1209 1410
|
|
|