Tab functionality for VBA form in Excel 2008 for mac / macintosh

D

drhalter

I have a workbook with multiple VBA forms that I created on Excel 2003 for
Windows. I'm in the process of making the workbook available on a mac
computer with Excel 2008. Much of the process is trial and error to get
certain functions working which are not available with the older version of
VBA available for Excel 2004 on the mac.

One of the problems I can't fix, however, is the tab functionality of the
VBA form. In windows, the form runs and you press tab to move the
activecontrol to each control in order. When I try tabbing on the mac,
nothing happens. I must click in each box to move the control. What is the
problem? Is it a bug in the macintosh or older VBA that just won't work, am
I missing an add-in or something, or is there a work around?

Any help will be appreciated.

Thanks
 
B

Bob Greenblatt

Sorry, I'm using Excel 2004 for Mac, not Excel 2008
I don't know what is wrong. This usually works fine. Have you properly
specified the tab order in the form? Are you sure the form is using forms
controls and not active-x controls?
 
D

drhalter

To clarify, this occurs not only with my previously written forms (on
Windows) but also if I make a simple new form in a new file using Mac's VBA
in Excel. If I put a couple of textboxes and buttons, the tabbing still
doesn't work. Note: I do have the Mac set to tab from textbox to textbox and
to buttons (a system setting).

Any thoughts?
drhalter
 
B

Bob Greenblatt

To clarify, this occurs not only with my previously written forms (on
Windows) but also if I make a simple new form in a new file using Mac's VBA
in Excel. If I put a couple of textboxes and buttons, the tabbing still
doesn't work. Note: I do have the Mac set to tab from textbox to textbox and
to buttons (a system setting).

Any thoughts?
drhalter
Well, I don't know. It works fine for me. Do you have the tab key
reassigned? Is the tab order correct? Can you explain in a little more
detail what the form looks like, which tools you used to build it, and what
happens when you press TAB?
 
D

drhalter

Bob Greenblatt said:
Well, I don't know. It works fine for me. Do you have the tab key
reassigned? Is the tab order correct? Can you explain in a little more
detail what the form looks like, which tools you used to build it, and what
happens when you press TAB?


In Apple Mac OS X, under Keyboard shortcuts, the Full Keyboard Access is set
as follows: In windows and dialogs, press Tab to move the keyboard focus
between: All controls. (Except for this standard option, I wouldn’t know how
to reassign the tab key). Changing this option to Textboxes and lists only
instead of All controls appears to change nothing in the scenario given below.

Using MS Excel 2004 11.3.3 for Mac OS X 10.4.1, I open a new workbook. I
then start Visual Basic Editor (with References to: Visual basic for
applications, Microsoft Excel 11.0 Object Library, OLE Automation, Microsoft
Forms 2.0 Object Library, and Microsoft Office 11.0 Object Library).


Next, I Insert… UserForm. A generic UserForm appears. I place a textbox,
and two commandbuttons.

Textbox1 has the following properties: AutoTab = False, TabIndex = 0,
TabKeyBehavior = False, TabStop = True

CommandButton1 has the following properties: Cancel = False, Default = True,
TabIndex = 1 and TabStop = True
CommandButton2 has the following properties: Cancel = True, Default = False,
TabIndex = 2 and TabStop = True

The only code is as follows:
Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
TextBox1.SetFocus
End Sub

UserForm Behavior is as follows. Using the run command from Visual Basic
Editor:
The cursor is set in TextBox1. I press tab and nothing happens. If I type
in TextBox1, then press Tab, the text is selected. CommandButtons 1 and 2 do
not change (1 is blue and 2 is grey).

If I add a TextBox, and change the Tab order to Textbox1 then 2,
CommandButton 1 then 2, the focus is set to TextBox1, I get the same behavior
in TextBox1, with no change in the rest of the form. If I set the focus to
TextBox2, I get the same behavior as in TextBox1.

If I use the Initialize code to CommandButton1.SetFocus, the tab button
appears to do nothing.

I noticed something at this point, I can move from control to control using
the up and down arrows (when controls are aligned up and down), or from
control to control using the side to side arrows when aligned from side to
side. I cannot move the focus out of a combobox added to the form, however,
using the up, down, or side arrows. Tab is still doing nothing.

Any ideas?

Thanks
drhalter
 
B

Bob Greenblatt

In Apple Mac OS X, under Keyboard shortcuts, the Full Keyboard Access is set
as follows: In windows and dialogs, press Tab to move the keyboard focus
between: All controls. (Except for this standard option, I wouldn¹t know how
to reassign the tab key). Changing this option to Textboxes and lists only
instead of All controls appears to change nothing in the scenario given below.

Using MS Excel 2004 11.3.3 for Mac OS X 10.4.1, I open a new workbook. I
then start Visual Basic Editor (with References to: Visual basic for
applications, Microsoft Excel 11.0 Object Library, OLE Automation, Microsoft
Forms 2.0 Object Library, and Microsoft Office 11.0 Object Library).


Next, I InsertŠ UserForm. A generic UserForm appears. I place a textbox,
and two commandbuttons.

Textbox1 has the following properties: AutoTab = False, TabIndex = 0,
TabKeyBehavior = False, TabStop = True

CommandButton1 has the following properties: Cancel = False, Default = True,
TabIndex = 1 and TabStop = True
CommandButton2 has the following properties: Cancel = True, Default = False,
TabIndex = 2 and TabStop = True

The only code is as follows:
Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
TextBox1.SetFocus
End Sub

UserForm Behavior is as follows. Using the run command from Visual Basic
Editor:
The cursor is set in TextBox1. I press tab and nothing happens. If I type
in TextBox1, then press Tab, the text is selected. CommandButtons 1 and 2 do
not change (1 is blue and 2 is grey).

If I add a TextBox, and change the Tab order to Textbox1 then 2,
CommandButton 1 then 2, the focus is set to TextBox1, I get the same behavior
in TextBox1, with no change in the rest of the form. If I set the focus to
TextBox2, I get the same behavior as in TextBox1.

If I use the Initialize code to CommandButton1.SetFocus, the tab button
appears to do nothing.

I noticed something at this point, I can move from control to control using
the up and down arrows (when controls are aligned up and down), or from
control to control using the side to side arrows when aligned from side to
side. I cannot move the focus out of a combobox added to the form, however,
using the up, down, or side arrows. Tab is still doing nothing.

Any ideas?

Thanks
drhalter
Yes, the Mac works differently here. Is the userform_initialize and
commandbutton2_click code on the userform's code page? I am not at all sure
what is happening in your case. When I follow your exact instructions, TAB,
when struck while the textbox is accepting data, enters the data and jumps
to the second text box. Pressing it again removes the focus from the second
text box, but does not highlight a button. (This is correct behavior on the
Mac.)

The Mac, just doesn't set focus like windows forms. The buttons may never
become highlighted. On the Mac, we click on buttons, not get to them via the
keyboard and then hit another key. The latter technique is against the mac
user guidelines.

But, I agree, the TAB key on your machine seems to be working differently
and in a non standard manner. What machine are you using? Is it an Apple
keyboard?
 

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