msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can we retain changes made to a form during runtime?

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions
Author Message
Yajiv



Joined: 26 Feb 2008
Posts: 1

PostPosted: Tue Feb 26, 2008 11:11 am    Post subject: Can we retain changes made to a form during runtime? Reply with quote

I have a userform in excel vba. I want to add buttons during runtime
as per user requirements.
I also want those buttons to be present when the user open it again.
is it possible?

Archived from group: microsoft>public>vb>general>discussion
Back to top
View user's profile Send private message
MP



Joined: 04 Oct 2007
Posts: 203

PostPosted: Tue Feb 26, 2008 1:58 pm    Post subject: Re: Can we retain changes made to a form during runtime? Reply with quote

You'll get better help on the .excel.programming group

"Yajiv" wrote in message @e23g2000prf.googlegroups.com...
>I have a userform in excel vba. I want to add buttons during runtime
> as per user requirements.
> I also want those buttons to be present when the user open it again.
> is it possible?

depending on exactly what you want to do, yes.
using me.controls.add you can add controls at runtime
using microsoft VisualBasic for Applications Extensibility 5.3 reference you
can write code on the fly and save it to your userform module
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Tue Feb 26, 2008 3:57 pm    Post subject: Re: Can we retain changes made to a form during runtime? Reply with quote

Yajiv wrote:
> I have a userform in excel vba. I want to add buttons during runtime
> as per user requirements.

Is this something you know to be possible? (I have no idea, myself, on this point.)

> I also want those buttons to be present when the user open it again.
> is it possible?

Sure, given the above. Just store your requirements somewhere, and read them as
needed.
--
..NET: It's About Trust!
http://vfred.mvps.org
Back to top
View user's profile Send private message
MP



Joined: 04 Oct 2007
Posts: 203

PostPosted: Tue Feb 26, 2008 9:03 pm    Post subject: Re: Can we retain changes made to a form during runtime? Reply with quote

"Karl E. Peterson" wrote in message
news:%234m$7lKeIHA.4704@TK2MSFTNGP03.phx.gbl...
> Yajiv wrote:
>> I have a userform in excel vba. I want to add buttons during runtime
>> as per user requirements.
>
> Is this something you know to be possible? (I have no idea, myself, on
> this point.)
>
>> I also want those buttons to be present when the user open it again.
>> is it possible?
>
> Sure, given the above. Just store your requirements somewhere, and read
> them as needed.
> --
> .NET: It's About Trust!
> http://vfred.mvps.org

fwiw it is possible to add controls at runtime(similar to vb)
I assume the op was talking about commandbuttons

but how to get at the _click event ?
Smile
I guess one could use vbe to rewrite the form code, save and reload the new
form, before calling f.show???

Public Sub AddCmdsRuntime(f As UserForm)
Dim lidx As Long, oCmd As CommandButton

For lidx = 0 To 5
Set oCmd = f.Controls.Add("Forms.CommandButton.1", "Cmd" & CStr(lidx),
True)
With oCmd
.Left = 10
.top = 15 * (lidx + 1)
LogEntry "Top " & .top

.Height = 10
.Width = 50
.Visible = True
.Caption = "Cmd" & CStr(lidx)
End With
Next lidx

End Sub
mark
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Tue Feb 26, 2008 8:48 pm    Post subject: Re: Can we retain changes made to a form during runtime? Reply with quote

MP wrote:
> "Karl E. Peterson" wrote ...
>> Yajiv wrote:
>>> I have a userform in excel vba. I want to add buttons during runtime
>>> as per user requirements.
>>
>> Is this something you know to be possible? (I have no idea, myself, on
>> this point.)
>>
>>> I also want those buttons to be present when the user open it again.
>>> is it possible?
>>
>> Sure, given the above. Just store your requirements somewhere, and read
>> them as needed.
>
> fwiw it is possible to add controls at runtime(similar to vb)
> I assume the op was talking about commandbuttons
>
> but how to get at the _click event ?
> Smile

Given there's no control arrays, that's the $64k question, isn't it! Beats me.

> I guess one could use vbe to rewrite the form code, save and reload the new
> form, before calling f.show???

Ouch! Sounds pretty nasty.
--
..NET: It's About Trust!
http://vfred.mvps.org

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group