Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBA Control Tab Index

I have several forms within an excel project and am trying to refer to
the controls, in the VBA code, on a given form by their tab index. For
example, let's say I want to set focus and active the control with an
index of 3.

I have been searching and am unable to get it right.

Can this be done?

Thanks,
Smithb2

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default VBA Control Tab Index

AFAIK, you'll need to loop through the entire Controls collection and, when
you find the control with the right tab index, set focus to it and exit the
loop. I've never done this while referencing TabIndexes but I suspect that
"On Error Resume Next" may be your best friend in this case since not all
controls will have a TabIndex property. There may be other issues involved
that I am unaware of.

(untested aircode)

Call SetFocusByTabIndex(Me,3)

Sub SetFocusByTabIndex(frm as Form, iTab as Integer)
On Error Resume Next
Dim ctl as Control

For each ctl in frm.Controls
If ctl.TabIndex = iTab Then
ctl.SetFocus
Exit For
End If
Next ctl
End Sub

HTH,
--
George Nicholson

Remove 'Junk' from return address.


wrote in message
ups.com...
I have several forms within an excel project and am trying to refer to
the controls, in the VBA code, on a given form by their tab index. For
example, let's say I want to set focus and active the control with an
index of 3.

I have been searching and am unable to get it right.

Can this be done?

Thanks,
Smithb2



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBA Control Tab Index

Thanks George...............I will see what I can come up with

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Index Numbers Richard Buttrey Excel Programming 3 August 18th 05 01:17 PM
Multipage Control Pages - Changing Index Value in Code misseill Excel Programming 1 July 13th 05 04:55 PM
Multipage Control Pages - Changing Index Value in Code misseill Excel Programming 0 July 13th 05 04:32 PM
Return Index of Control Object Clicked! gr8guy Excel Programming 3 May 11th 04 05:24 AM
Accesing a combobox control via it index propertie in VBA, Is itPossible? Muxer Excel Programming 3 July 30th 03 08:20 PM


All times are GMT +1. The time now is 12:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"