Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default EXCEL USERFORM

Gary

Here's a sub in the Initialize event that will find all the jpg's in a
folder and list them on your userform.

Private Sub UserForm_Initialize()

Dim Fldr As String
Dim FName As String
Dim i As Long
Dim cnt As Control

Fldr = "C:\My Documents\My Pictures\"

FName = Dir(Fldr & "*.jpg")
i = 10

Do While Len(FName) 0
Set cnt = Me.Controls.Add("forms.checkbox.1", , True)
cnt.Top = i
cnt.Left = 10

Set cnt = Me.Controls.Add("forms.label.1", , True)
cnt.Top = i
cnt.Left = 30
cnt.Caption = FName

i = i + 30
FName = Dir
Loop

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Gary Burke" wrote in message
...
Hi there,

Have a desire/need to populate a userform (continuous form ??) with a
list of files from a folder (of a selected type only - pictures), and
provide the facility to search other folders, so am guessing that i
would list the selected files(of a given type) and folders. I know I
could use the interface to windows, to activate the windows "Open File"
dialogue box, but dont to do that.

I would also like to have on the form, a check box, against each file
listed, so the user may "select" the file they wish to use. Propose
adding an "execute" button, to do something with the file once selected.
This will be to insert the picture into a designated area on the excel
worksheet, and to resize it.




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default EXCEL USERFORM

That code works great, Dick. The only problem is if you have more than
a few .jpg's, you can't see them. My suggestion is to put a frame on
this form and then put the following code into the Enter event of the
frame:

Private Sub Frame1_Enter()

Dim Fldr As String
Dim FName As String
Dim i As Long
Dim cnt As Control

Fldr = "C:\documents and settings\markbi\My Documents\My Pictures\"

FName = Dir(Fldr & "*.jpg")
i = 10

Do While Len(FName) 0
Set cnt = Me.Frame1.Controls.Add("forms.checkbox.1", , True)
cnt.Top = i
cnt.Left = 10

Set cnt = Me.Frame1.Controls.Add("forms.label.1", , True)
cnt.Top = i
cnt.Left = 30
cnt.Caption = FName

i = i + 30
FName = Dir
Loop

Me.Frame1.ScrollHeight = i

End Sub

Again, just a slight improvement to already great code!

Mark

---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default EXCEL USERFORM


Thanks guys, that works great. However, would like to expand the code
now to do 2 things.

1. List folders, so that the user can change the active folder, and
refresh the list of files.

2. Allow the user to do something with the selected file/folder. What
code would i use, to say insert the selected file at a given location
(ie how do i reference the selected file), and what code would I use to
change the folder, if the user selected a folder instead of a file ?

Maybe the checkbox concept was the wrong way, or maybe there is a better
way ???

Thanks in advance.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default EXCEL USERFORM

Gary

You should consider using the GetOpenFileName method instead of trying to
program all this stuff yourself. It won't give you quite the interface
you're looking for, but it will save you hours of programming. Check it out
in help.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Gary Burke" wrote in message
...

Thanks guys, that works great. However, would like to expand the code
now to do 2 things.

1. List folders, so that the user can change the active folder, and
refresh the list of files.

2. Allow the user to do something with the selected file/folder. What
code would i use, to say insert the selected file at a given location
(ie how do i reference the selected file), and what code would I use to
change the folder, if the user selected a folder instead of a file ?

Maybe the checkbox concept was the wrong way, or maybe there is a better
way ???

Thanks in advance.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Automatic Userform Excel 2003 BJ&theBear Excel Discussion (Misc queries) 2 March 16th 10 08:58 PM
VBA with userform in excel [email protected] Excel Discussion (Misc queries) 5 July 11th 07 11:24 PM
display status bar value in excel userform? Al B Excel Discussion (Misc queries) 0 November 15th 06 01:21 PM
Userform in excel ST Excel Discussion (Misc queries) 2 July 13th 06 10:16 AM


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