How do I create Folders/Sub folders from User Form control button

I have a User Form that I would like to take one of the spare control buttons 
and have it set up my job folder on the hard drive.

I am not sure how to code it to achive the following results:


These are my text box ID's

Main Folder
---------------------------------------------------------------------
User Selects drive: \ CES_No_1 \ CLLI_Code_1\ TEO_No_1


Sub Folders inside Main Folder
----------------------------------------------------------------------
Completed Drawings
Elec Job Folder
Misc Job Documents
Site Pictures


0
Utf
2/23/2010 12:02:01 AM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
916 Views

Similar Articles

[PageSpeed] 5

If you can dig up a copy of the VBS documentation in a CHM file, it'll tell 
you about the FileSystemObject, which lets you create files and folders and 
do other cool stuff.  You can use it in VBA as well as in VBScript, and it's 
definitely what I would use for this.  I think you can also find 
documentation on it in MSDN.

--- "Brian" wrote:
> I have a User Form that I would like to take one of the spare control buttons 
> and have it set up my job folder on the hard drive. I am not sure how to
> code it....
0
Utf
2/23/2010 9:51:01 AM
How would I let the user select the drive to create the directory on? Ever 
thing I see is for when you know the directory is on C: or D:, but what if 
there are several drives for the user to choose from?

This what I have figured out so far. The .value are the values the user put 
into the text boxes.

mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value"
mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Completed Drawings"
mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Elec Job Folder"
mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Misc Job Documents"
mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Site Pictures"

"Bob Bridges" wrote:

> If you can dig up a copy of the VBS documentation in a CHM file, it'll tell 
> you about the FileSystemObject, which lets you create files and folders and 
> do other cool stuff.  You can use it in VBA as well as in VBScript, and it's 
> definitely what I would use for this.  I think you can also find 
> documentation on it in MSDN.
> 
> --- "Brian" wrote:
> > I have a User Form that I would like to take one of the spare control buttons 
> > and have it set up my job folder on the hard drive. I am not sure how to
> > code it....
0
Utf
2/23/2010 1:25:01 PM
Two comments. First, you mkdir lines are incorrect. 

>mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value"

should be

mkdir "\CES_No_1.value\CLLI_Code_1.value\"  & TEO_No_1.value

if TEO_No_1 is the name of the text box in which a value is entered.
As you wrote the code, the TEO_No_1.value is within the quotes that
that string, not the value of the text box, would be included in the
directory name.

Second. Below is some code that will allow you to prompt the user for
a drive. You'll need to set a reference to the scripting runtime. In
VBA, go to the Tools menu, choose References, and scroll down to and
check the item named "Microsoft Scripting Runtime". 

Function GetDrive(LocalOnly As Boolean, _
        FixedOnly As Boolean, _
        FixedAndOptical As Boolean) As String
Dim FSO As Scripting.FileSystemObject
Dim DRV As Scripting.Drive
Dim DVs() As String
Dim M As Long
Dim N As Long
Dim S As String
Dim Include As Boolean

LocalOnly = False
FixedOnly = False
FixedAndOptical = True

Set FSO = New Scripting.FileSystemObject
ReDim DVs(1 To FSO.Drives.Count)
For Each DRV In FSO.Drives
    Include = True
    If LocalOnly = True Then
        If DRV.DriveType = Remote Then
            Include = False
        End If
    End If
    If FixedOnly = True Then
        If DRV.DriveType <> Fixed Then
            Include = False
        End If
    End If
    If FixedAndOptical = True Then
        If DRV.DriveType <> Fixed And DRV.DriveType <> CDRom Then
            Include = False
        End If
    End If
    If Include = True Then
        If DRV.IsReady = True Then
            M = M + 1
            DVs(M) = DRV.DriveLetter
            S = S & vbCrLf & DRV.DriveLetter & " (" & DRV.VolumeName &
")"
        End If
    End If
Next DRV

ReDim Preserve DVs(1 To M)
S = UCase(Application.InputBox("Select A Drive" & S, _
    "Select A Drive", , , , , , 2))
If S = vbNullString Then
    GetDrive = vbNullString
    Exit Function
Else
    For M = LBound(DVs) To UBound(DVs)
        If DVs(M) = S Then
            GetDrive = DVs(M)
            Exit Function
        End If
    Next M
End If
GetDrive = vbNullString

End Function


The parameter to this functions are:
	LocalOnly	If True, do not list remote, mapped drives
	FixedOnly	If True, list only hard drives, no optical
drives
	FixedAndOptical	If True, list both hard drives and optical
drivecs.

You an call this function with code like

Dim S As String
S = GetDrive(True, False, True)
If Len(S) > 0 Then
    Debug.Print "selected drive: " & S
Else
    Debug.Print "no selection"
End If


Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
	Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Tue, 23 Feb 2010 05:25:01 -0800, Brian
<Brian@discussions.microsoft.com> wrote:

>How would I let the user select the drive to create the directory on? Ever 
>thing I see is for when you know the directory is on C: or D:, but what if 
>there are several drives for the user to choose from?
>
>This what I have figured out so far. The .value are the values the user put 
>into the text boxes.
>
>mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value"
>mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Completed Drawings"
>mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Elec Job Folder"
>mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Misc Job Documents"
>mkdir "\CES_No_1.value\CLLI_Code_1.value\TEO_No_1.value\Site Pictures"
>
>"Bob Bridges" wrote:
>
>> If you can dig up a copy of the VBS documentation in a CHM file, it'll tell 
>> you about the FileSystemObject, which lets you create files and folders and 
>> do other cool stuff.  You can use it in VBA as well as in VBScript, and it's 
>> definitely what I would use for this.  I think you can also find 
>> documentation on it in MSDN.
>> 
>> --- "Brian" wrote:
>> > I have a User Form that I would like to take one of the spare control buttons 
>> > and have it set up my job folder on the hard drive. I am not sure how to
>> > code it....
0
Chip
2/23/2010 9:52:49 PM
Reply:

Similar Artilces:

Print Command Button Corrupted
Hi Guys, Does anyone know how to recreate a corrupted button in Excel 2000? Basically the Print button comes up with error messages when I press onto it. Printing works fine if you select from the File menu, it is just the button. I thought there was a tool to recreate buttons but cannot find it. I have also run detect and repair which did nothing (Surprise surprise! lol) Any ideas would be much appreciated. Try this: In Excel XP, View, Toolbars, Customize. Select the Standard toolbar and Click the Reset Button. Note, that this will cause any customization that you may have made to you...

Outlook 2003 Junk E-Mail Folder is Sub Folder Under Notes
In the user's Exchange Private Mailbox, the Junk E-Mail folder in Outlook 2003 SP2 is located as a subfolder under Notes and spam mail is not being filtered. How do I restore the folder back to its proper location? Thanks! dhan74@gmail.com <dhan74@gmail.com> wrote: > In the user's Exchange Private Mailbox, the Junk E-Mail folder in > Outlook 2003 SP2 is located as a subfolder under Notes and spam mail > is not being filtered. How do I restore the folder back to its proper > location? Try running Outlook once with the /resetfolders command line switch. See http...

CRM 3.0/4.0: Views to show record that is created X Days Ago
I have a simple requirement to create a View with condition that the record is created x days ago, for example the record that is created 3 days ago. The only operator that is available for datetime (e.g. createdon) is only Last X Days, which if i show Last 3 Days, will show the records that were created today, yesterday, and 2 days ago. Is there any operator or any way to show the record that were created 3 days ago? I try to put condition "createdon Last 3 Days" and "NOT createdon Last 2 days", but there is no "NOT" operator in CRM. I try to insert new attribut...

Error removing replica from "SYSTEM CONFIGURATION" Public Folder
I want to remove an Exchange server from the replication tab on the "SYSTEM CONFIGURATION" public folder (Exchange System Folder). I am logged on with full rights however when I remove the server I get prompted for a username and password. No matter what I type I cannot remove any of the servers and eventually I get this error:-- "Exchange System Manager The operation failed. ID no: 80004005 Exchange System Manager OK" Any ideas? I am running Exchange 2003 with SP1. DB, Is the other machine inaccessible? You might want to try turning it back on and then remove t...

spreadsheet does not print as large as created
I have created a spreadsheet in Excel 2002. Simple layout with number, name, address,blank, blank,number. I created with large font size (28 or 32). I want the columns large enough for me to write in blanks and make notes. When the document is printed (hp laser 5p) the size of the font is not increased. Jim Morgan Memphis Tn Probably because that printer (driver) will not support that font and/or size. -- Don Guillett SalesAid Software Granite Shoals, TX donaldb@281.com "Jim Morgan" <jmorgan7@midsouth.rr.com> wrote in message news:06ce01c34dfe$29c53d90$a401280a@phx.gb...

New Problem
In 2007: In a form I created a button, used the wizard to set it to go to next record when clicked. When I click it, I get this: The expression ON CLICK you entered as the event property setting produced the following error: Ambiguous name detected: PRINT_CLICK. Now, if I wrote the VBA/Macro, I could understand it not working if I made a mistake, but this button was generated by ACCESS and doesn't work. Same problem with Previous record button and Save Record button. Thanks in advance, Vito On 13 May 2010 16:00:59 GMT, Vito wrote: > In 2007: > > In ...

Create rule to run script
I have a vb script that when run takes the attachment on an e-mail and places it in a folder. Is there any way to setup a rule in outlook that when an e-mail is received from a certain person or address, to automatically run this script to place the attachment in the specified folder? Thanks in advance what version? -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outl...

how do i create a local client rule for outlook 2003
hello has anyone ever been able to create a local client rule for outlook 2003? exchange 2003? I can create the rule to send it to a PST (i dont know whether this can be done) then when i run the rule it says there is an error with the rule and it turns red. Does anyone have the steps for how to get this to work? Thanks A does the pst exist and is it in your profile? -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Author, Google and Other Search Engines (Visual QuickStart Guide) Outlook Tips: htt...

create a database
Steve can you email me I really need a database created as well and will pay you the fee. Sheryl On Sun, 21 Mar 2010 10:26:01 -0700, Sheryl <Sheryl@discussions.microsoft.com> wrote: >Steve can you email me I really need a database created as well and will pay >you the fee. Sheryl Luckily for you, he can't, because he doesn't know your email address. Don't post it here, or even worse spammers than Steve will pick it up. I would recommend that you find someone (perhaps locally) who can help you, rather than paying someone who has habitually and constantl...

Creating a Combination Bar Chart with 2 Lines
I am trying to create a bar chart with 2 line series. The Y-axis for the vertical bars would be on the left and the Y-axis for the 2 line series would be on the right (3 series were defined). The horizontal axis for all series are calendar months (Jan, Feb, etc.) Every time I setup the chart my chart only displays a single line, ignoring the other line series. The vertical bars come out fine. Any thoughts on what I am doing wrong? Thanks Bill Falzone Don't use the built in types. Make the chart using all columns. Select a series that you want to change (click on it right in th...

My ActiveX controls have disappeared
I have an Excel spreadsheet that I inadvertantly did something to cause all my ActiveX controls to disappear. All the underlying functions are still in the file but I can't see any checkboxes or command buttons. Further the Control toolbar in the file is greyed out. All my other files with ActiveX control continue to work fine. What have I done? ...

Passing data between forms
Hi I am working on a project someone else started, and he has this code: If STR_FormName = "FMS_ToDo" Then Page47.SetFocus He obviously expects the name of the last form to be here, but it is not. In fact, when I put Option Explicit at the top - this field was undefined. How is this supposed to work? Stapes ...

How do I add a detail section to the form?
I have found instructions on how to add a header/footer but can't find how to add a detail section. A form always has a detail section. It can have only one detail section. -- Dave Hargis, Microsoft Access MVP "kjv77" wrote: > I have found instructions on how to add a header/footer but can't find how to > add a detail section. ...

Custom Form Error, publih to server
Hi All I'm trying to publish a new form I have created on the Administrator account of the exchange server, in outlook. When I go to publish in the Org. Forms Library, I receive the following error, "An error has occured when trying to access this folder." As this is an admin account, I am trying to find out what the error is and why it's happening, but to no avail. Anyone have any ideas or suggestions Much Appreciated Jason ...

Noob Question For Selecting Multiple Fields On A Form
Hello... In versions earlier than 2007 I would be able to go to the Menu Bar and click Edit -> Select All to select all fields on the form. Now, my question is... where in 2007 did the put that functionality? If Microsoft removed it from there... where did they recreate it? Thanks! Squirrel "SQLSQUIRREL" <SQLSQUIRREL@discussions.microsoft.com> wrote in message news:333547A1-9C6A-422B-9CD5-97D79D6037DF@microsoft.com... > Hello... > > In versions earlier than 2007 I would be able to go to the Menu Bar and > click Edit -> Select All to se...

URGENT!!! Problem with row data being truncated in a copy worksheet sub #2
Dave, Thanks for responding. I tried this but I could not get it t work in conjunction with the entire module. It dies right afte copying and PasteSpecial Values It does not kill the temp file or loa the newly created sheet into an e-mail. Any Ideas -- Doctor ----------------------------------------------------------------------- DoctorV's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=514 View this thread: http://www.excelforum.com/showthread.php?threadid=26863 You may want to post your current procedure. DoctorV wrote: > > Dave, Thanks for respon...

creating a function for dividing two columns
I am trying to keep track of softball stats. I trying to make a column of batting averages. I have at bats in column b, hits in column c with the results in column d. I cant get the function right so it will display the correct result. use this =SUM(C1/B1) in cell D1. Format D1 as a number with 3 decimal places. Steve Hubbard "cflan" <cflan@discussions.microsoft.com> wrote in message news:212BF952-55B9-45DF-BC8C-E8B670FA6010@microsoft.com... > I am trying to keep track of softball stats. I trying to make a column of > batting averages. I have at bats in column b,...

BadMail Folder #5
I recently installed Exchange Server 2003. I notice that my BadMail folder is filling up with all kinds of rejected mail from other servers that was supposedly sent from my domain, but it wasn't. Is this normal? How can I stop the mail from going into this folder? Is there a way I can just direct it to cyberspace? Thanks in advance.. FYI, http://support.microsoft.com/default.aspx?scid=kb;en-us;884068 http://support.microsoft.com/default.aspx?scid=kb;en-us;555164 http://support.microsoft.com/default.aspx?scid=kb;en-us;867642 -- Jammyù�ٴ� "Bob Becker" <bob@becker.o...

How can I convert my Archive Folder from its OL2002 style to the new OL2003 style?
Dear friends: The size of my Archive Folder is approaching 2 GB. How can I convert my Archive Folder from its OL2002 style to the new OL2003 style? I understand that the OL2003 style doesn't have the 2 GB limitation. I use Outlook 2003. Any hint? Thanks Juan I. Cahis Santiago de Chile (South America) Note: Please forgive me for my bad English, I am trying to improve it! In news:1kp8j1le66sp3j25022kl7pktvbj63hnrp@4ax.com, Juan I. Cahis <jiclbch@SINBASURAattglobal.net> typed: > Dear friends: > > The size of my Archive Folder is approaching 2 GB. > > How can I conv...

Cusotm Office 2007 install for English, Spanish, & Chinese users
Hi, I'm working on creating a custom install of Office 2007 for my various sites. These sites include users that speak English, Spanish and Chinese. I am a bit confused on how to use language packs in order to provide multi-lingual support. From my understanding, I need to download the Spanish and Chinese language pack and place the .msp files in the Updates folder on my network install point? Does this mean when office gets installed on a Chinese computer it will be in Chinese automatically? Or does the user need to "flip a switch" to make it Chinese language? The ...

send as another user
i gave one user right to access another user mailbox and enable "send on behalf" of him/her in exchange. back in outlook, when the user highlight the other user inbox and click on send...it still say his send from his name instead of the other user name? am i doing someting wrong? if so, can someone tell me how to make this thing work? thx in advance. "send on behalf" is NOT "send as" theyre 2 totally different things. send as is given via ADUC "vincentnyc" <vincentnyc@discussions.microsoft.com> wrote in message news:F2A6FD12-5080-47...

Howdo I stop code execution with the Cancel button?
Hi I have a procedure that takes a while and the user might want to hi cancel. How can I make the Cancel button replicate the cntrl brea event and unload the form? Cheers Gromi -- Gromi ----------------------------------------------------------------------- Gromit's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=92 View this thread: http://www.excelforum.com/showthread.php?threadid=31469 ...

Creating a time chart
Can someone tell me if this is possible. I want to be able to create a chart that represents a week. There will be seven bars and each bar will represent the day my business is open. I want to be able to enter starting times in one column, let's say column B and a quitting times in column C. These two columns represent Sunday. I want D and E to represent Monday. I'll do this for all seven days. Is there a way I can create a stacking bar chart (or any chart) that will place a bar representing that employee's shift in the chart. All bars will not start on the horizontal axis, b...

NDR on Public Folders when certain servers try to replicate
We have a multi site Exchange 2003/2000 server environment and I am noticing NDR messages similar to the following being sent to the postmaster: Undeliverable:Delivery Status Notification (Failure) Your message did not reach some or all of the intended recipients. Subject: Sent: 17/10/2005 15:34 The following recipient(s) could not be reached: Public Folder Store (Exch2k3svr) on 17/10/2005 15:35 You do not have permission to send to this recipient. For assistance, contact your system administrator. <smtp.domain.co.uk #5.7.1> If I click on ...

Draft Folder problem #2
I'm running outlook 2000. My draft folder is called draft1. Can't seem to rename it! There isn't a folder named draft so what's happening? Isn't a big problem, but I should be able to solve it and I can't. Help. Thanks in advance Peter You could try to start Outlook from the run line with the /resetfoldernames switch. Start-->Run outlook.exe /resetfoldernames Reference: http://office.microsoft.com/en-gb/assistance/HP010031101033.aspx "Peter Brown" <peter.jennifer@gmail.com> wrote in message news:TErag.449$TF.2645@news-1.opaltelecom.net... &...