Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Shape Names on User Form

I have created a user form that will be used to display the names of about 50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.

I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.

Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want? I
realize I can cut and paste and just have to change the xx part. But it sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?

--
Bill @ UAMS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Shape Names on User Form

Bill,
Shapes are used on sheets, Controls are used on UserForms.
On a userform you can iterate thru the controls collection...

For each ctrl in UserForm1.Controls
ctrl.Name = "Sludge"
Next
--
Jim Cone
Portland, Oregon USA



"BillCPA" <Bill @ UAMS
wrote in message
I have created a user form that will be used to display the names of about 50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.
I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.
Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want? I
realize I can cut and paste and just have to change the xx part. But it sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?
--
Bill @ UAMS
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Shape Names on User Form

When I try that, it tells me I cannot set the Name property at runtime. Is
there any way around that?

--
Bill @ UAMS


"Jim Cone" wrote:

Bill,
Shapes are used on sheets, Controls are used on UserForms.
On a userform you can iterate thru the controls collection...

For each ctrl in UserForm1.Controls
ctrl.Name = "Sludge"
Next
--
Jim Cone
Portland, Oregon USA



"BillCPA" <Bill @ UAMS
wrote in message
I have created a user form that will be used to display the names of about 50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.
I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.
Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want? I
realize I can cut and paste and just have to change the xx part. But it sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?
--
Bill @ UAMS

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Shape Names on User Form

You could add your controls at runtime, sized and positioned to suit.
You could then refer to your controls by index rather than by name.

Regards,
Peter T

"BillCPA" <Bill @ UAMS wrote in message
...
I have created a user form that will be used to display the names of about
50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.

I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The
first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.

Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want?
I
realize I can cut and paste and just have to change the xx part. But it
sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?

--
Bill @ UAMS



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Shape Names on User Form

I'm not sure how you know which controls get renamed to what names, but maybe
this will help you get started.

Option Explicit
Sub Change_Labels_UserForm()
Dim oVBComp As Object
Dim ctl As Control
Dim lCtr As Long

lCtr = 0

Set oVBComp = ThisWorkbook.VBProject.vbcomponents("Userform1")
For Each ctl In oVBComp.Designer.Controls
If TypeOf ctl Is MSForms.Label Then
lCtr = lCtr + 1
ctl.Name = "DataFormName" & Format(lCtr, "00") & "Lbl"
End If
Next ctl
End Sub




BillCPA wrote:

I have created a user form that will be used to display the names of about 50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.

I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.

Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want? I
realize I can cut and paste and just have to change the xx part. But it sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?

--
Bill @ UAMS


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Shape Names on User Form

I'm not sure if this will help you (maybe if you have multiple userforms to
update), but here's a post from Rob Bovey that I kept (and the basis for my
previous response):

Sub Change_Labels_UserForm()
Dim oVBComp As Object
Dim ctl As Control
On Error Resume Next
For Each oVBComp In ThisWorkbook.VBProject.VBComponents
If oVBComp.Type = 3 Then
For Each ctl In oVBComp.Designer.Controls
If TypeName(ctl) = "Label" And ctl.ControlTipText = "" Then
ctl.ControlTipText = ctl.Caption
End If
Next ctl
End If
Next oVBComp
End Sub

The oVBComp.Type = 3 line means that it'll only process UserForms.



Dave Peterson wrote:

I'm not sure how you know which controls get renamed to what names, but maybe
this will help you get started.

Option Explicit
Sub Change_Labels_UserForm()
Dim oVBComp As Object
Dim ctl As Control
Dim lCtr As Long

lCtr = 0

Set oVBComp = ThisWorkbook.VBProject.vbcomponents("Userform1")
For Each ctl In oVBComp.Designer.Controls
If TypeOf ctl Is MSForms.Label Then
lCtr = lCtr + 1
ctl.Name = "DataFormName" & Format(lCtr, "00") & "Lbl"
End If
Next ctl
End Sub

BillCPA wrote:

I have created a user form that will be used to display the names of about 50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.

I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.

Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want? I
realize I can cut and paste and just have to change the xx part. But it sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?

--
Bill @ UAMS


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Shape Names on User Form

This is awesome. I've needed (wanted) something like this for years.

If I have 50 controls I want on a form that need to be numbered sequentially
(FormControlnnCkBx), I can just create a separate form, create one CheckBox,
copy and paste 'til I get 50, run the macro to name them (nn=01 to 50), and
copy them to the form I want them on.

Thanks so much!

--
Bill @ UAMS


"Dave Peterson" wrote:

I'm not sure if this will help you (maybe if you have multiple userforms to
update), but here's a post from Rob Bovey that I kept (and the basis for my
previous response):

Sub Change_Labels_UserForm()
Dim oVBComp As Object
Dim ctl As Control
On Error Resume Next
For Each oVBComp In ThisWorkbook.VBProject.VBComponents
If oVBComp.Type = 3 Then
For Each ctl In oVBComp.Designer.Controls
If TypeName(ctl) = "Label" And ctl.ControlTipText = "" Then
ctl.ControlTipText = ctl.Caption
End If
Next ctl
End If
Next oVBComp
End Sub

The oVBComp.Type = 3 line means that it'll only process UserForms.



Dave Peterson wrote:

I'm not sure how you know which controls get renamed to what names, but maybe
this will help you get started.

Option Explicit
Sub Change_Labels_UserForm()
Dim oVBComp As Object
Dim ctl As Control
Dim lCtr As Long

lCtr = 0

Set oVBComp = ThisWorkbook.VBProject.vbcomponents("Userform1")
For Each ctl In oVBComp.Designer.Controls
If TypeOf ctl Is MSForms.Label Then
lCtr = lCtr + 1
ctl.Name = "DataFormName" & Format(lCtr, "00") & "Lbl"
End If
Next ctl
End Sub

BillCPA wrote:

I have created a user form that will be used to display the names of about 50
people and certain information about them (all 50 at once). Each person's
name will be on a label shape, and there will be 2-3 other labels and 2-3
text boxes for each person.

I want to have my own names for the labels and text boxes - say,
DataFormNamexxLbl for the label that will have the person's name. The first
person listed will be xx=1, next xx=2, etc. Same for the remaining labels
and text boxes.

Is there any way to set the Name parameter for all the DataFormNamexxLbl
shapes besides tediously going to each one and typing in the name I want? I
realize I can cut and paste and just have to change the xx part. But it sure
would be nice if there was a way to quickly set all the names?

Anyone have any ideas?

--
Bill @ UAMS


--

Dave Peterson


--

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
Date field in user form & Loading a user form on opening workbook Balan Excel Programming 1 May 24th 08 03:40 PM
VBA code to list names of controls on user form? Peter[_59_] Excel Programming 3 July 31st 06 09:33 AM
Shape names Andrew B[_4_] Excel Programming 5 April 8th 06 04:30 PM
Problem with Shape Names containing punctuation Peter T Excel Programming 2 March 24th 05 04:31 PM
Shape names Don Rouse Excel Programming 1 July 7th 04 12:21 AM


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