Changing object properties permanently at runtime

  • Thread starter Thread starter Darv
  • Start date Start date
D

Darv

Hi,

I'm having trouble changing the properties of objects permanently at
runtime. Specifically, I am trying to make a commandbutton visible at
runtime. This works fine, but when I reset the VBA code, the
commandbutton returns to it's state prior to running the code.

Thanks for any help anyone can give.

David
 
David,
Yes, that is the difference in meaning between "Design Time" and "Run Time".
If you want a property to be set for the next time you open that workbook,
you need to change it the Design time.

NickHK
 
Hi Nick,

I understand that, but is it possible to change a design time property
at runtime?

David
 
Hi David,

Sub Test()
Dim dForm As UserForm

Set dForm = ThisWorkbook.VBProject.VBComponents("Userform1").Designer
dForm.CommandButton2.Caption = Time

End Sub

You can't do this while Userform1 is loaded (AFAIK). Can also add/delete
controls.

(You'll need trust access to vb projects in xl2002+)

Regards,
Peter T
 
Perfect thanks!


Peter said:
Hi David,

Sub Test()
Dim dForm As UserForm

Set dForm = ThisWorkbook.VBProject.VBComponents("Userform1").Designer
dForm.CommandButton2.Caption = Time

End Sub

You can't do this while Userform1 is loaded (AFAIK). Can also add/delete
controls.

(You'll need trust access to vb projects in xl2002+)

Regards,
Peter T
 

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

Back
Top