Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2008, 11:29 PM
Authorized User
 
Join Date: Jun 2008
Location: sydney, nsw, Australia.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mona_upm84
Default List name of item from folder 'My Picture'

How can i list item from folder 'My Picture' into a combobox. For example: I got 3 pictures named 'Vacation.jpg', 'Graduation.jpg' and 'Party.jpg' and i want them to be list into the combobox.

How can I do that?

Regads,
Mona

 
Old September 4th, 2008, 01:55 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Assuming that the Combobox is on a userform, here is the code

Sub Add_Pics()

Dim sPath As String
Dim sDir

sPath = "c:\Documents and Settings\160831\My Documents\My Pictures\"

sDir = Dir(sPath & "*.jpg")
Do Until Len(sDir) = 0
    ComboBox1.AddItem sDir
    sDir = Dir
Loop


End Sub

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old September 4th, 2008, 05:54 PM
Authorized User
 
Join Date: Jun 2008
Location: sydney, nsw, Australia.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mona_upm84
Default

Hi Shasur,

Thanks, you always helps me... It really work. I changed the coding a little bit. I put in userform_initialize() like this:


Private Sub UserForm_Initialize()
Dim sPath As String
Dim sDir

sPath = "C:\Documents and Settings\Monal\My Documents\My Pictures\"

sDir = Dir(sPath & "*.jpg")
Do Until Len(sDir) = 0
    ComboBox1.AddItem sDir
    sDir = Dir
Loop
End Sub


Anyway, thanks.... That really help me lots...

Regards,
Mona





Similar Threads
Thread Thread Starter Forum Replies Last Post
Invisible List Item? The Duke ASP.NET 3.5 Professionals 0 September 1st, 2008 12:14 PM
Get the first item of a List hpox ASP.NET 2.0 Basics 1 February 16th, 2007 06:04 PM
How to populate list item shankhan Classic ASP Databases 5 March 23rd, 2005 04:03 AM
saving picture from word to other folder DorisTan VB How-To 0 December 3rd, 2004 02:46 AM
Picture in dropdown list Tachyophan Excel VBA 1 May 21st, 2004 01:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.