![]() |
Changing design time properties at runtime
Hi All,
Is it possible to change the design time property of an object at runtime? In my case I am trying to make a button visible at runtime, and keep the setting permanently once the macro finishes. I asked a similar question earlier but didn't word it very well. Thanks again David |
Changing design time properties at runtime
UserForm1.CommandButton1.Visible = True / False If you only want to them to be greyed out: UserForm1.CommandButton1.Enabled = True / False "Darv" schreef in bericht ups.com... Hi All, Is it possible to change the design time property of an object at runtime? In my case I am trying to make a button visible at runtime, and keep the setting permanently once the macro finishes. I asked a similar question earlier but didn't word it very well. Thanks again David |
Changing design time properties at runtime
Hi,
This works until the macro is reset, when all the runtime property changes are also reset to their design time values. Anyone know how to get round this? David |
Changing design time properties at runtime
Problem sorted. See "Changing object properties permanently at runtime"
to see solution. David |
Changing design time properties at runtime
this is some sample code to make a permanent change to a userform using code
(this changed the caption on some commandbuttons): Sub abc() Dim vc As Object Dim rng As Range, cell As Range Dim i As Long Set vc = ThisWorkbook.VBProject.VBComponents("UserForm1") Set rng = Worksheets("Sheet1").Range("A1:A52") i = 0 For Each cell In rng i = i + 1 vc.Designer.Controls("CommandButton" & i) _ .Caption = Format(cell.Value, "mm_dd_yyyy") Next End Sub I doubt you can do this while the form is displayed, but you could record the runtime changes you made, then implement them with code like this after you unload the form. Just remember that at some point, you will need to save the workbook. -- Regards, Tom Ogilvy "Darv" wrote: Hi, This works until the macro is reset, when all the runtime property changes are also reset to their design time values. Anyone know how to get round this? David |
Changing design time properties at runtime
That's perfect thanks!
I had to run this code with the form unloaded, like you said. For anyone else trying it you cannot (obviously) run this code from a subroutine in the form, because you can't unload a form from within itself (I don't think). Cheers, David |
All times are GMT +1. The time now is 02:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com