Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Button in userform


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

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
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
USERFORM X BUTTON Greg B[_11_] Excel Programming 2 November 6th 07 04:21 PM
OK Button in UserForm Jack_Feeman Excel Programming 3 October 19th 06 12:43 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Userform button Greg B[_5_] Excel Programming 2 May 18th 05 11:28 AM
Use the X button on a userform Greg B Excel Discussion (Misc queries) 3 May 16th 05 09:19 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"