Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Changing design time properties at runtime

Problem sorted. See "Changing object properties permanently at runtime"
to see solution.

David

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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

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
Changing object properties permanently at runtime Darv Excel Programming 4 September 21st 06 10:00 AM
Unable to see Properties in Design View for controls ts1 Excel Worksheet Functions 0 September 22nd 05 07:55 PM
Design time events Josh Sale Excel Programming 2 December 3rd 04 07:39 PM
changing design in excel from VB.NET Tomek[_6_] Excel Programming 1 June 16th 04 12:13 PM
Properties not visible in design mode dave Excel Programming 0 May 1st 04 04:36 PM


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