Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Create File Folder

I am new to this VBA thing so any help would be welcome.

I need to create a file folder for all of the companies
listed in column F of my worksheet. I have a button on
the worksheet with the following line of code attached
but can not see how to move down to the next row.

Also is there a way to check if the folder exists, if it
does to ignore it and move to the next row.

Thanks

Andy


Private Sub CommandButton1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createfolder("E:/Customers and Contacts/")

a.Close


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Create File Folder


"Andy" wrote in message
...
I am new to this VBA thing so any help would be welcome.

I need to create a file folder for all of the companies
listed in column F of my worksheet. I have a button on
the worksheet with the following line of code attached
but can not see how to move down to the next row.

Also is there a way to check if the folder exists, if it
does to ignore it and move to the next row.

Thanks

Andy


Private Sub CommandButton1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createfolder("E:/Customers and Contacts/")

a.Close


End Sub


This is what I found. It looks pretty similar to your code except for the
"/" you have at the end of the path. Remove it and see what happens. Oh,
make sure the folder doesn't exist when you run the code. You may want to do
that in your code in order to avoid errors.
Sub CreateFolder
Dim fso, fldr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.CreateFolder("C:\MyTest")
Response.Write "Created folder: " & fldr.Name
End Sub/Fredrik


  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Create File Folder

Fredrik

Thanks, but how do I add the company name on each row of
my worksheet to the end of E:/customers and contacts/

I need to get for example

E:/customers and contacts/companyA
E:/customers and contacts/companyB
E:/customers and contacts/companyC

This will all come from column F on my worksheet.

Thanks in advance

Andy
-----Original Message-----

"Andy" wrote in

message
...
I am new to this VBA thing so any help would be

welcome.

I need to create a file folder for all of the companies
listed in column F of my worksheet. I have a button on
the worksheet with the following line of code attached
but can not see how to move down to the next row.

Also is there a way to check if the folder exists, if

it
does to ignore it and move to the next row.

Thanks

Andy


Private Sub CommandButton1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createfolder("E:/Customers and Contacts/")

a.Close


End Sub


This is what I found. It looks pretty similar to your

code except for the
"/" you have at the end of the path. Remove it and see

what happens. Oh,
make sure the folder doesn't exist when you run the

code. You may want to do
that in your code in order to avoid errors.
Sub CreateFolder
Dim fso, fldr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.CreateFolder("C:\MyTest")
Response.Write "Created folder: " & fldr.Name
End Sub/Fredrik


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Create File Folder


wrote in message
...
Fredrik

Thanks, but how do I add the company name on each row of
my worksheet to the end of E:/customers and contacts/

I need to get for example

E:/customers and contacts/companyA
E:/customers and contacts/companyB
E:/customers and contacts/companyC

This will all come from column F on my worksheet.

Thanks in advance

Andy


I'm not sure I understand. Do you have the paths in some cells? In that case
you must loop over this range. Here's a link:
http://www.ozgrid.com/VBA/VBALoops.htm

/Fredrik


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create File Folder

Private Sub CommandButton1_Click()
Dim i As Long
Dim cLastRow As Long

cLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 To cLastRow
mkdir cells(i,"A").Value
Next i

End Sub

This assumes your folder names start in A1, and go down column A, and that
the folder E:/customers and contacts/exists already.

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
...
Fredrik

Thanks, but how do I add the company name on each row of
my worksheet to the end of E:/customers and contacts/

I need to get for example

E:/customers and contacts/companyA
E:/customers and contacts/companyB
E:/customers and contacts/companyC

This will all come from column F on my worksheet.

Thanks in advance

Andy
-----Original Message-----

"Andy" wrote in

message
...
I am new to this VBA thing so any help would be

welcome.

I need to create a file folder for all of the companies
listed in column F of my worksheet. I have a button on
the worksheet with the following line of code attached
but can not see how to move down to the next row.

Also is there a way to check if the folder exists, if

it
does to ignore it and move to the next row.

Thanks

Andy


Private Sub CommandButton1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createfolder("E:/Customers and Contacts/")

a.Close


End Sub


This is what I found. It looks pretty similar to your

code except for the
"/" you have at the end of the path. Remove it and see

what happens. Oh,
make sure the folder doesn't exist when you run the

code. You may want to do
that in your code in order to avoid errors.
Sub CreateFolder
Dim fso, fldr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.CreateFolder("C:\MyTest")
Response.Write "Created folder: " & fldr.Name
End Sub/Fredrik


.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Create File Folder

Does this work:

Private Sub CommandButton1_Click()
Dim i As Interger
Dim LRow As integer

LRow = Cells(Rows.Count,"F").End(xlUp).Row
For i = 1 To LRow
MkDir "E:/Customers and Contacts/" & cells(i,"F").Value
Next i

End Sub

"Bob Phillips" wrote:

Private Sub CommandButton1_Click()
Dim i As Long
Dim cLastRow As Long

cLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 To cLastRow
mkdir cells(i,"A").Value
Next i

End Sub

This assumes your folder names start in A1, and go down column A, and that
the folder E:/customers and contacts/exists already.

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
...
Fredrik

Thanks, but how do I add the company name on each row of
my worksheet to the end of E:/customers and contacts/

I need to get for example

E:/customers and contacts/companyA
E:/customers and contacts/companyB
E:/customers and contacts/companyC

This will all come from column F on my worksheet.

Thanks in advance

Andy
-----Original Message-----

"Andy" wrote in

message
...
I am new to this VBA thing so any help would be

welcome.

I need to create a file folder for all of the companies
listed in column F of my worksheet. I have a button on
the worksheet with the following line of code attached
but can not see how to move down to the next row.

Also is there a way to check if the folder exists, if

it
does to ignore it and move to the next row.

Thanks

Andy


Private Sub CommandButton1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createfolder("E:/Customers and Contacts/")

a.Close


End Sub

This is what I found. It looks pretty similar to your

code except for the
"/" you have at the end of the path. Remove it and see

what happens. Oh,
make sure the folder doesn't exist when you run the

code. You may want to do
that in your code in order to avoid errors.
Sub CreateFolder
Dim fso, fldr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.CreateFolder("C:\MyTest")
Response.Write "Created folder: " & fldr.Name
End Sub/Fredrik


.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create File Folder

Is this a question to me or the OP? If so, it is basically the same as mine,
but doesn't match his specification, namely the cell contains the full path.
And you should not use an Integer variable for the line count, as there are
more lines in an Excel spreadsheet than an integer can hold.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"gocush" /delete wrote in message
...
Does this work:

Private Sub CommandButton1_Click()
Dim i As Interger
Dim LRow As integer

LRow = Cells(Rows.Count,"F").End(xlUp).Row
For i = 1 To LRow
MkDir "E:/Customers and Contacts/" & cells(i,"F").Value
Next i

End Sub

"Bob Phillips" wrote:

Private Sub CommandButton1_Click()
Dim i As Long
Dim cLastRow As Long

cLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 To cLastRow
mkdir cells(i,"A").Value
Next i

End Sub

This assumes your folder names start in A1, and go down column A, and

that
the folder E:/customers and contacts/exists already.

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
...
Fredrik

Thanks, but how do I add the company name on each row of
my worksheet to the end of E:/customers and contacts/

I need to get for example

E:/customers and contacts/companyA
E:/customers and contacts/companyB
E:/customers and contacts/companyC

This will all come from column F on my worksheet.

Thanks in advance

Andy
-----Original Message-----

"Andy" wrote in
message
...
I am new to this VBA thing so any help would be
welcome.

I need to create a file folder for all of the companies
listed in column F of my worksheet. I have a button on
the worksheet with the following line of code attached
but can not see how to move down to the next row.

Also is there a way to check if the folder exists, if
it
does to ignore it and move to the next row.

Thanks

Andy


Private Sub CommandButton1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createfolder("E:/Customers and Contacts/")

a.Close


End Sub

This is what I found. It looks pretty similar to your
code except for the
"/" you have at the end of the path. Remove it and see
what happens. Oh,
make sure the folder doesn't exist when you run the
code. You may want to do
that in your code in order to avoid errors.
Sub CreateFolder
Dim fso, fldr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.CreateFolder("C:\MyTest")
Response.Write "Created folder: " & fldr.Name
End Sub/Fredrik


.






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
create a file list from a folder? Hal239 Excel Discussion (Misc queries) 2 February 5th 09 03:32 PM
how do you create file folder labels in excel? rebecca_vsp New Users to Excel 2 May 16th 08 02:00 AM
can I create backup file in separate folder from the original? MCC Wong Setting up and Configuration of Excel 9 January 19th 08 01:06 AM
How do I Create backup of excel file in other folder khalid Excel Discussion (Misc queries) 1 May 24th 05 11:01 AM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM


All times are GMT +1. The time now is 12:07 PM.

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

About Us

"It's about Microsoft Excel"