PC Review


Reply
Thread Tools Rate Thread

Button in userform

 
 
Jarle
Guest
Posts: n/a
 
      3rd Apr 2008

I store a list of documents in an array called Hitfiles.
The size of this array may vary.

I create buttons in an userform using VBA like this. (I leave out info like
position of button)

For i = LBound(Hitfiles) To UBound(Hitfiles)
With .Controls.Add("Forms.CommandButton.1", "Button" & i, True)
.Caption = Filename
.Name = "button" & i
End With

If array has 5 elements, then 5 buttons called Button1, Button2....Button5
will be created in the userform. (Array is size 1 to 5)

I want document 1 to open when I press button 1, document 2 to open when I

How can I run a macro from the buttons I have just created?

Thanks!

rgds
Jarle
 
Reply With Quote
 
 
 
 
Jarle
Guest
Posts: n/a
 
      3rd Apr 2008
I think I can solve this with tip from
http://www.j-walk.com/ss/excel/tips/tip44.htm

All buttons start the same macro - openfile. Filename to open decided by
button no and document array.


Jarle skrev:

>
> I store a list of documents in an array called Hitfiles.
> The size of this array may vary.
>
> I create buttons in an userform using VBA like this. (I leave out info like
> position of button)
>
> For i = LBound(Hitfiles) To UBound(Hitfiles)
> With .Controls.Add("Forms.CommandButton.1", "Button" & i, True)
> .Caption = Filename
> .Name = "button" & i
> End With
>
> If array has 5 elements, then 5 buttons called Button1, Button2....Button5
> will be created in the userform. (Array is size 1 to 5)
>
> I want document 1 to open when I press button 1, document 2 to open when I
>
> How can I run a macro from the buttons I have just created?
>
> Thanks!
>
> rgds
> Jarle

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PP 2000: can't create button/menu in button bar to start userForm =?Utf-8?B?QmFsZXg=?= Microsoft Powerpoint 9 12th Nov 2005 10:35 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Microsoft Excel Programming 6 27th Jul 2005 12:57 PM
Userform button Greg B Microsoft Excel Programming 2 18th May 2005 11:28 AM
The userform X button Esben Microsoft Excel Programming 2 3rd Jun 2004 03:11 PM
UserForm Button Help meflorence Microsoft Excel Programming 2 2nd Mar 2004 05:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:47 PM.