Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How can I find type of control on a form

I would like to loop through all controls on a custom form and only process
those that are checkbox controls, or textboxes, or labels, etc.

In VBA form module, I was thinking it would be possible to do something like
this:

dim c as control

for each c in me.controls
if c.type = xlcheckbox (or whatever the correct constant should be) then
checkboxCount = checkboxCount + 1
end if
next c

The problem is that there isn't a type property for a control. Can someone
tell me how to do this. I read in help that it was possible to loop thru
the controls on worksheets by looping through the shapes collection, testing
to see if it is a control, then testing to see if it is a checkbox; however
I am interested in looping through controls on a form.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How can I find type of control on a form

How about...

dim C as control
for each c in me.controls
if typeof c is msforms.checkbox then
'it's a checkbox
end if
next c



John T Ingato wrote:

I would like to loop through all controls on a custom form and only process
those that are checkbox controls, or textboxes, or labels, etc.

In VBA form module, I was thinking it would be possible to do something like
this:

dim c as control

for each c in me.controls
if c.type = xlcheckbox (or whatever the correct constant should be) then
checkboxCount = checkboxCount + 1
end if
next c

The problem is that there isn't a type property for a control. Can someone
tell me how to do this. I read in help that it was possible to loop thru
the controls on worksheets by looping through the shapes collection, testing
to see if it is a control, then testing to see if it is a checkbox; however
I am interested in looping through controls on a form.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How can I find type of control on a form

Perfect.. Thank you Dave.

"Dave Peterson" wrote in message
...
How about...

dim C as control
for each c in me.controls
if typeof c is msforms.checkbox then
'it's a checkbox
end if
next c



John T Ingato wrote:

I would like to loop through all controls on a custom form and only
process
those that are checkbox controls, or textboxes, or labels, etc.

In VBA form module, I was thinking it would be possible to do something
like
this:

dim c as control

for each c in me.controls
if c.type = xlcheckbox (or whatever the correct constant should be)
then
checkboxCount = checkboxCount + 1
end if
next c

The problem is that there isn't a type property for a control. Can
someone
tell me how to do this. I read in help that it was possible to loop thru
the controls on worksheets by looping through the shapes collection,
testing
to see if it is a control, then testing to see if it is a checkbox;
however
I am interested in looping through controls on a form.


--

Dave Peterson



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
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
Control on a form to find a record Terry Excel Discussion (Misc queries) 2 September 7th 08 03:04 PM
How can I find type of control on a form John T Ingato Excel Programming 1 November 5th 06 10:09 PM
Tool Tip Text for Form control/ Active-X control Freddie[_2_] Excel Programming 0 October 19th 04 04:14 AM
Identifying a Control Type Chrissy[_4_] Excel Programming 5 July 30th 03 08:25 AM


All times are GMT +1. The time now is 10:59 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"