View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2398_] Rick Rothstein \(MVP - VB\)[_2398_] is offline
external usenet poster
 
Posts: 1
Default Change all label controltiptexts in userform

Thanks for clearing that up for me. As for not being able to do it in VB6...
while I'm still not 100% sure of what the OP is after, I would think
preserving changes should theoretically be able to be done by writing out
the changes to a file or the registry in some coded fashion and then reading
them back in when the UserForm is initialized.

Rick


"Peter T" <peter_t@discussions wrote in message
...
Rick, the OP is asking about programmatically "designing" a Userform
(actually all the userforms), such that when the code terminates the
changes
to control properties persist. Unfortunately there's no VB6 equivalent
method.

Regards,
Peter T

"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not 100% sure what you are asking here. First, we are talking about

the
controls on a UserForm, right? Second, are you asking to change the
ControlTipText for Labels only? If so, is the condition that Labels
**without** a ControlTipText assigned to it should show its own Caption

(and
those that do have a ControlTipText assign to it should continue to show
that)? If so, give this code a try...

Sub Change_Labels_UserForm()
Dim ctl As Control
For Each ctl In UserForm1.Controls
If TypeOf ctl Is MSForms.Label Then
If ctl.ControlTipText = "" Then ctl.ControlTipText = ctl.Caption
End If
Next
End Sub

Rick


wrote in message
...
Hi guys,

This is driving me insane!!!

I'm trying to have the text of all of the controltiptext properties on
a userform to be the same as the caption property of the label
(there's loads of labels).

It seemed like it should have been easy, but after much trial and
error I've managed to come up with the following (which I don't quite
follow) and feels so close, but I'm stumped as to get the caption in
the

Sub Change_Labels_UserForm()
Dim oVBProj, oVBComp As Object
Dim ctl As Control

Set oVBProj = ThisWorkbook.VBProject

On Error Resume Next
For Each oVBComp In oVBProj.VBComponents
If oVBComp.Type = 3 Then
For Each ctl In oVBComp.Designer.Controls
If Left(ctl.Name, 5) = "Label" and ctl.ControlTipText = ""
Then ctl.ControlTipText = 'caption name
Next
End If
Next
End Sub

Any ideas?

Cheers,
JF