Populate combobox with folder names

I had found this code to show folder names that displays in a msgbox,
is it possible to get the list of folder names into a combobox?

---------------------------------------

Sub ListFolders()
    Dim fs, f, f1, fc, s
    Dim folderspec
    folderspec = "C:\Excel\"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.SubFolders
    For Each f1 In fc
        s = s & f1.Name
        s = s & vbCrLf

    Next
    MsgBox s


End Sub


----------------------------------------

This is for excel 2000

Thanks
0
damorrison
2/18/2010 11:53:33 PM
excel.programming 6508 articles. 2 followers. Follow

6 Replies
3708 Views

Similar Articles

[PageSpeed] 5

is the combobox on a worksheet or a userform?
0
dan
2/19/2010 12:05:39 AM
On Feb 18, 5:05=A0pm, dan dungan <stagerob...@yahoo.com> wrote:
> is the combobox on a worksheet or a userform?

Thanks for the reply, it will be from the controlls toolbar that will
be on the worksheet.
0
damorrison
2/19/2010 12:12:49 AM
Option Explicit
Sub ListFolders()
    Dim fs, f, f1, fc, s
    Dim folderspec
    folderspec = "C:\Excel\"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.SubFolders
    For Each f1 In fc
        Worksheets("Sheet1").ComboBox1.AddItem f1.Name
    Next f1
End Sub

Change the name of the worksheet and the name of the combobox if you have to.

damorrison wrote:
> 
> On Feb 18, 5:05 pm, dan dungan <stagerob...@yahoo.com> wrote:
> > is the combobox on a worksheet or a userform?
> 
> Thanks for the reply, it will be from the controlls toolbar that will
> be on the worksheet.

-- 

Dave Peterson
0
Dave
2/19/2010 1:06:37 AM
Thank you, that works great
0
damorrison
2/19/2010 3:08:00 AM
On Feb 18, 8:08=A0pm, damorrison <davemcochr...@gmail.com> wrote:
> Thank you, that works great

The code works well.

When I use it on a system that uses two screens, and click the
ComboBox, the list shows up on the opposite  screen as the combobox. I
then used a UserForm instead to populate the combobox, placing the
code in UserForm_Initialize, it populated just fine, but then again,
when I click the combobox in the UserForm, the list still shows up in
the opposite screen instead of the screen with the userform, is there
a way to stop this from happening?
0
damorrison
2/20/2010 12:36:02 AM
I don't understand.

The code puts the list in a combobox on Sheet1.  I don't see anything that uses
a userform.

damorrison wrote:
> 
> On Feb 18, 8:08 pm, damorrison <davemcochr...@gmail.com> wrote:
> > Thank you, that works great
> 
> The code works well.
> 
> When I use it on a system that uses two screens, and click the
> ComboBox, the list shows up on the opposite  screen as the combobox. I
> then used a UserForm instead to populate the combobox, placing the
> code in UserForm_Initialize, it populated just fine, but then again,
> when I click the combobox in the UserForm, the list still shows up in
> the opposite screen instead of the screen with the userform, is there
> a way to stop this from happening?

-- 

Dave Peterson
0
Dave
2/20/2010 1:33:59 PM
Reply:

Similar Artilces:

Personal Folders #2
Hi, I really need some help........... I made a personal folder and always put my emails in seperate sub-folders after I read them. We have to keep our inbox fairly small or the server statrts yelling at us. PROBLEM! My personal folder is now just over 2gig in size. Outlook 2000 won't let me access the file. It says there is an error and to use the inbox scan to fix it. I use SCANPST.EXE, but even it comes up with a error. Is there a 3rd party program that will let me access this file? Maybe I can go in and delete some things to get it below the 2gig limit. Please email m...

Lost Public Folders with Digital ID
Hi, I'm using Exchange 2003 with SP1 and a CA Server. I created my own Digital ID that I installed on my Outlook 2003. Somehow I lost my public folders after the installation. How do I get this back? Please advise. Digital ID is working fine except the above problem. And I got slow response when the root is not offline and subordinate have CRLs to execute. Does root need to be online when CRLs need to be executed? Thanks, Ricky Can you see these folders via another Outlook client? I have never seen a certificate cause public folders to disappear. When you say the root CA is...

Can not remove Public Folder Store in Front End Server
Hello, When trying to delete a PF Store in a new FE server you get the error: "... Can't ...contains replicas ... move to another server ..." Selecting 'move all replicas' and waiting a day doesn't help. Dismounting the Store, and deleting the edb and stm files and remounting to delete doesn't work. No Mailbox Databases point to this PF Store, I changed the Mailbox Database PF 'affinity' to another BE Server. I've setup 5+ FE servers over the years, so not my first shot at this. But, it is the first time I've done it since SP2 was out...

Populating Excel from CSV
Hello all, I need to know how to populate an Excel template with data from a external CSV file. Let's say I have this nice pretty colourful templat that is far more pleasing to the eye than the usual chunk of importe CSV data, what are some methods to populate it with data from a CS file?? Any ideas or suggestions or redirections would be much appreciated. Thanks in advance : -- AJMorgan59 ----------------------------------------------------------------------- AJMorgan591's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2777 View this thread: http://www.ex...

Public folder favorite disappears
Hi. We are using Outlook 2003 sp 3 and Exchange 2003 sp1. One of our users adds subfolders of a public folder to her public folder favorites, but after a short period (10minutes - 1 day) the folder disappears from her public folder favorite list. When she adds it again, the same thing happens. I am lost as to why this keeps happening. Does anyone have any suggestions? Thanks in advance for any help. J. Huber I have not encountered this, however, the public folder favorites are stored in the OST/PST file. Knowing this, I would guess that the problem lies in the synchronization of the pub...

Sequence Not populated for the MO Numbers during Data Collection
When data collection is done for the MO Numbers by using the Data Collection Window under Manufaturing, the Sequnce look up does not show the whole list, it only shows NOTES, for the user to select and enter the necessary data. why does this happen in the case of some MO Numbers and in the others it shows all the sequnces as NOTES,MAKE READY, PRESS RUN, WASH UP, MAINTENANCE, REPAIRS, REWIND/INSPECTION, etc. Any information would be much appreciated -- Thanks AshaM It should show all of the router steps. Are some of your steps possibly marked to backflush labor? These steps would not...

Machine Name change not being recognized by SQL
When running this: master.dbo.sp_add_log_shipping_primary_database I get the following error: Msg 14262, Level 16, State 1, Procedure sp_add_jobserver, Line 88 The specified @server_name ('oldname') does not exist. Note that the machine name for server 'oldname' was changed to 'newname' and rebooted. As expected, @@servername and serverproperty('servername') return 'newname' However, somehow oldserver is getting added to the job and, of course, it is coming back as not existing. What has to be done to the SQL instance to get it to...

Junk mail folder
Hi, If my users run in cached mode is there any way to turn off the junk mail folder? I have an excellent spam solution and Outlook is falsely identifying valid mail as spam. I don't see how to turn it off in cached mode, are the two "features" tied together? Thanks, Dan Do you mean besides the Actions -> Junk E-mail -> Junk E-mail Options -> No Automatic Filtering selection ? You can also get to it via the Tools, Options, Junk E-mail button. -- Ben Winzenz Exchange MVP MessageOne Read my blog! http://winzenz.blogspot.com http://feeds.feedburner.com/winzenz (...

Public Folders have disappeared in Outlook 2003
Running Outlook 2003 in an Exchange 2000 organization. I upgraded my Outlook 2002 to version 2003. Now Public Folders have disappeared. What happened to them? Everyone with Outlook 2002 still has them. Have you clicked on the Folders icon in the Navigation Bar? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the SWEN virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Spin asked: | Running Outlook 2003 in an Exchange 2000 organization. I upgraded ...

An inbox folder refuses to be deleted
I have an inbox subfolder that went buggy. It started when no new mail could be moved into it. I tried deleting the old mail from it and got an error every time. I renamed it and moved it to the Deleted Items folder. I then tried to permanently delete it but get a permissions error when I do. Anyone have an idea how to get rid of this. My only other idea is to create a new PST and move everything else into it. Thanx Log into the computer as an administrator. You probably can't delete it because you don't have the correct permissions. "Aahzmandos" <anonymous@discu...

how do populate empty cells with the contents of populated cells .
I have this worksheet problem. The work sheet is thousands of rows long. One of my columns has cells not populated. I would like to get any empty cell in this column to populate itself with the contents of the next populated cell below it? Kind of a "find and replace" action where by an empty cell says to it self;"I'm going fill myself in with the next thing I find below me" I would greatly appreciate if someone can relate how to do this. Thanks Jim, Select the column, use Edit | Go To... Special , Blanks, OK. Then type an equal sign, press the down arrow...

folder is a read only file
I am trying to publish to the web. I go through all the steps and have done this several times. Lately I have not had any luck in get my edit sight posted. It comes back and tells me that it can't save the folder is marked as read only. I am using publisher 2003. think you inadvance Right-click the file, properties, clear "read only." Are you trying to upload from removable media? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "d54fj" <d54fj@discussions.microsoft.com> wrote in message news:91C29...

Public folder error ID no: 80090308
When trying to administer the public folders, I get the following message from the Exchange system Manager The token supplied to the function is invalid ID no: 80090308 I can't find anything in the knowledge base for this, has anyone else seen it? I have a feeling my public store db has been corrupted Remove the requirement on the public folders virtual directory to require SSL. -- Tyrone Cowart Microsoft PSS Please do not send email directly to this alias. This alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no r...

Autoplay for Pictures Not Populated
I inserted my XD card in to my card reader today and the autoplay pop up window asking what I wanted Windows to do was blank. For Video, Music and Mixed content the options are there but not for Pictures - it is just blank. I have tried running autofix.exe but this has not fixed it. Any ideas? Is this a Microsoft problem or has something else caused this? It worked fine until today. Thanks. Peachypumpkin wrote: > I inserted my XD card in to my card reader today and the autoplay > pop up window asking what I wanted Windows to do was blank. For > Video, Music and Mi...

ComboBox not showing contents
I've been trying to get my ComboBox controls to show their drop down menu in an MFC dialog based app; but all I ever see is a thin black line under the bottom of the control when I click on the drop down arrow. I tried creating a new dialog project, and tested the ComboBox control again to have the exact same results. I have tried to add static data in the resource editor; and tried to dynamically add strings during run time. The data is there, when I use the arrow keys to find it. Has anyone else experienced this problem? I have XP SR2, VS.NET 2003. Anyhelp would be wonderfu...

How I can make a passward on the folder?
I'm new user of Microsoft. plz tip me for getting knowledge. Question is not clear. However windows, by default will not provide folder protection, if you want to protect folder on your computer, search in Google.com for such softwares. "Malik" wrote: > I'm new user of Microsoft. plz tip me for getting knowledge. Or check out Start>Help on "permissions" Gord Dibben MS Excel MVP On Tue, 22 Aug 2006 02:35:02 -0700, Naveen <Naveen@discussions.microsoft.com> wrote: >Question is not clear. > >However windows, by default will not provide ...

Cannot Empty Deleted Items Folder
Suddenly I cannot empty the deleted items folder. Windows Mail works well otherwise. Temporary solution was to move all the mail to my SpamFighter folder which was quite happy to delete it. Any ideas as to how to get the normal empty delete items command to work again please? How to Remove a Stuck Undeletable Message in Windows Mail http://www.vistax64.com/tutorials/62560-windows-mail-problems.html WMUtil http://www.oehelp.com/WMUtil/Default.aspx -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Alan C" <user@msgroups.net/> wrote in m...

City and State Populated by Zip Code
Does anyone know of a way to load a program that when you type in the Zip Code the City and State are automatically populated? I have seen a MSCRM add-in from a company called QAS (http://www.qas.com/). This is more than just Zip Code/City&State. It's a full address validator along with streamlined data entry. They have integrated with CRM via an ISV pop-up and it seems to work fairly smoothly. Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On 15 Apr 2005 11:13:56 -0700, "Morgan" <tzeoli@att.net> wr...

Populating a field
I want to populate a description field based on a par number that is entered in the field before it. In other owrds, you enter a part number and presto, in the next field, the description is entered for you. Can you help?? Thanx Tom On Thu, 6 Dec 2007 08:48:01 -0800, Tom <Tom@discussions.microsoft.com> wrote: >I want to populate a description field based on a par number that is entered >in the field before it. In other owrds, you enter a part number and presto, >in the next field, the description is entered for you. > >Can you help?? > >Thanx >Tom If yo...

How to open another user's folder list?
Hello, I have Outlook 2002 SP3 and Windows XP SP2. In my Folder List I have my mailbox expanded showing all my folders (inbox, calendar, contacts, etc.). I also have the mailbox for our general company email account (info@) that receives the emails submitted from our website. But when I click on the + sign next to it to expand it, I get a message saying "Unable to expand the folder. The set of folders could not be opened. The operation failed." This company email is set up as it's own user on our network, and I am set as it's delegate with full control over all it's ...

"stuck folder"
I have a user who somehow, managed to move his Junk-Email folder to be a subfolder of the journal. When I try to move it back, it tells me that I cannot move system folders. Does anyone know a way to move it back? I have tried both in Outlook and in OWA. Please let me know. thanx, On 19 Mar 2007 14:48:37 -0700, "whoolly" <whoolly@gmail.com> wrote: >I have a user who somehow, managed to move his Junk-Email folder to be >a subfolder of the journal. >When I try to move it back, it tells me that I cannot move system >folders. >Does anyone know a way to move it bac...

Populate Textbox
Hi, I have a table with part numbers and locations. There are multiple locations per part number. I would like to populate a listbox with a filtered list of the locations for the part number shown on my form. I'm not very good at vba and have been looking all over for code, but can't find anything suitable. Thanks You have multiple locations per part number. So first, let's get your form set up correctly. When you have a one-to-many format (one salesman, many products or one part number, many locations) you need a form and subform. The Mainform would be for...

owner of public folders
Hello! We have an Ex5.5-SRV -as a public folder SRV- with 2.000 public folders on it! Problem: Who created the folder XYZ? Good question? Let's say the "owner" of the publich folder xyz is the person, who we are looking for. Question: Has Microsoft any tools to search all of them and create a list with the name of the folder and the name of the "owner"? I know about 3rd-party tools, but they are not for free :-) Thanks! Best Regards Soheil pfinfo, pfdavadmin are Microsoft tools. On Thu, 14 Apr 2005 14:52:05 -0700, Soheil <Soheil@discussions.microsoft.com>...

retrieving a moved folder
Im in outlook 2007 and have contacts i selected to move to folder now their gone, how can I undo this action? You can't of course. Doubt the Contacts are gone since you didn't delete them. Figure out what you did wrong. We can't figure that out for you. You were there. We weren't. Do you know how to search for data? -- Russ Valentine "Tina" <Tina@discussions.microsoft.com> wrote in message news:27ABA39B-F906-4869-A330-B71DEEE6B4CE@microsoft.com... > Im in outlook 2007 and have contacts i selected to move to folder now > their > gone, ...

Rules, move message to folder
I have a few email accounts, for different purposes (work, school, private and so on), and i have created rules to move the incoming messages to a folder for the account. For example, all emails arrived to the kgafvert[at]ilopia.com email account is moved to the ilopia.com folder. This worked fine in the beginning, but now i have a need to move some emails (_from_ a specified email account) to a specific folder. For example, i get some firewall logs from an email address, and i want to move all the emails from this email address to the "Firewall" folder. I have created a rule ...