Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 16
Default CREATE A FOLDER AUTOMATICALLY

1.I wish to create a folder everytime I add a new customer in my customer list
2.For example, when I add a customer using the FORM under DATA, I enter the
customer code (eg ABC,BUZ,CKF...), customer name,customer address.The
customer code is in column A, starting at A2
3.For the new customer,by using a micro ,I want to create a new folder (eg.
"K:\TRIALQUOTATIONS\BUZ") .
4.In future the customer's quotations will be filed in this folder.
5.I had written the following micro, which is giving "run time error 438"

Sub CREATECUSTOMERFOLDER()

ActiveWorkbook.CreateFolder FolderName:="K:\TRIALQUOTATIONS\" &
Sheets("CUSLIST").[A2]
6.Please advise suitable changes in the micro.
End Sub
excelforautomatinginvoicing
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 245
Default CREATE A FOLDER AUTOMATICALLY

Perhaps the easiest way is to force past the error using On Error Resume
Next

Sub test()
Dim dirname

dirname = "K:\TRIALQUOTATIONS\" & Sheets("CUSLIST").[A2]

On Error Resume Next
MkDir (dirname)
'if the above produces an error (directory exists)
'the error will be ignored,
' that line of code will be skipped
On Error GoTo 0
'get back error control
'display a standard runtime error box

'your code

End Sub

For more on error trapping see:
http://www.cpearson.com/excel/ErrorHandling.htm

--
Steve

"pravin" wrote in message
...
1.I wish to create a folder everytime I add a new customer in my customer
list
2.For example, when I add a customer using the FORM under DATA, I enter
the
customer code (eg ABC,BUZ,CKF...), customer name,customer address.The
customer code is in column A, starting at A2
3.For the new customer,by using a micro ,I want to create a new folder
(eg.
"K:\TRIALQUOTATIONS\BUZ") .
4.In future the customer's quotations will be filed in this folder.
5.I had written the following micro, which is giving "run time error 438"

Sub CREATECUSTOMERFOLDER()

ActiveWorkbook.CreateFolder FolderName:="K:\TRIALQUOTATIONS\" &
Sheets("CUSLIST").[A2]
6.Please advise suitable changes in the micro.
End Sub
excelforautomatinginvoicing


  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1,533
Default CREATE A FOLDER AUTOMATICALLY

Hi

Sub test()
Dim DirName

DirName = "K:\TRIALQUOTATIONS\" & Sheets("CUSLIST").Range("A2").Value

Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FolderExists(DirName) Then
MkDir (DirName)
End If
set fs=Nothing
'your code
End Sub

Regards,
Per

"pravin" skrev i meddelelsen
...
1.I wish to create a folder everytime I add a new customer in my customer
list
2.For example, when I add a customer using the FORM under DATA, I enter
the
customer code (eg ABC,BUZ,CKF...), customer name,customer address.The
customer code is in column A, starting at A2
3.For the new customer,by using a micro ,I want to create a new folder
(eg.
"K:\TRIALQUOTATIONS\BUZ") .
4.In future the customer's quotations will be filed in this folder.
5.I had written the following micro, which is giving "run time error 438"

Sub CREATECUSTOMERFOLDER()

ActiveWorkbook.CreateFolder FolderName:="K:\TRIALQUOTATIONS\" &
Sheets("CUSLIST").[A2]
6.Please advise suitable changes in the micro.
End Sub
excelforautomatinginvoicing


  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 16
Default CREATE A FOLDER AUTOMATICALLY

Thanks Per Jessen
1.Your suggestion works beautifully.
2.However,it creates folder for the customer with the code in cell A2.
3. The customer codes are entered in cells A2 to A201 . These customers will
be entered as and when we get new customers.
4.To create another folder for another customer in cell A3, I have to change
the Range to "A3" in the micro, and so on.
5.Is it not possible that the range can be automatically changed by the
micro in such a way that
- whenever a new customer code is entered, the micro will create a new
folder corresponding to the new customer code, without disturbing the
existing folders,
created previously.


--
excelforautomatinginvoicing


"Per Jessen" wrote:

Hi

Sub test()
Dim DirName

DirName = "K:\TRIALQUOTATIONS\" & Sheets("CUSLIST").Range("A2").Value

Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FolderExists(DirName) Then
MkDir (DirName)
End If
set fs=Nothing
'your code
End Sub

Regards,
Per

"pravin" skrev i meddelelsen
...
1.I wish to create a folder everytime I add a new customer in my customer
list
2.For example, when I add a customer using the FORM under DATA, I enter
the
customer code (eg ABC,BUZ,CKF...), customer name,customer address.The
customer code is in column A, starting at A2
3.For the new customer,by using a micro ,I want to create a new folder
(eg.
"K:\TRIALQUOTATIONS\BUZ") .
4.In future the customer's quotations will be filed in this folder.
5.I had written the following micro, which is giving "run time error 438"

Sub CREATECUSTOMERFOLDER()

ActiveWorkbook.CreateFolder FolderName:="K:\TRIALQUOTATIONS\" &
Sheets("CUSLIST").[A2]
6.Please advise suitable changes in the micro.
End Sub
excelforautomatinginvoicing



  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 16
Default CREATE A FOLDER AUTOMATICALLY

Thanks for your suggestion.
It gets over the problem of showing the error message but does not create a
folder.
--
excelforautomatinginvoicing


"AltaEgo" wrote:

Perhaps the easiest way is to force past the error using On Error Resume
Next

Sub test()
Dim dirname

dirname = "K:\TRIALQUOTATIONS\" & Sheets("CUSLIST").[A2]

On Error Resume Next
MkDir (dirname)
'if the above produces an error (directory exists)
'the error will be ignored,
' that line of code will be skipped
On Error GoTo 0
'get back error control
'display a standard runtime error box

'your code

End Sub

For more on error trapping see:
http://www.cpearson.com/excel/ErrorHandling.htm

--
Steve

"pravin" wrote in message
...
1.I wish to create a folder everytime I add a new customer in my customer
list
2.For example, when I add a customer using the FORM under DATA, I enter
the
customer code (eg ABC,BUZ,CKF...), customer name,customer address.The
customer code is in column A, starting at A2
3.For the new customer,by using a micro ,I want to create a new folder
(eg.
"K:\TRIALQUOTATIONS\BUZ") .
4.In future the customer's quotations will be filed in this folder.
5.I had written the following micro, which is giving "run time error 438"

Sub CREATECUSTOMERFOLDER()

ActiveWorkbook.CreateFolder FolderName:="K:\TRIALQUOTATIONS\" &
Sheets("CUSLIST").[A2]
6.Please advise suitable changes in the micro.
End Sub
excelforautomatinginvoicing





  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 16
Default CREATE A FOLDER AUTOMATICALLY

Hi Per Jessen,

Thanks.
I have got the program working with a DO loop
which creates the folder, if a new customer is added.
I have also been able to have the path shown in the customer table for the
folder.
Thanks again.
--
excelforautomatinginvoicing


"Per Jessen" wrote:

Hi

Sub test()
Dim DirName

DirName = "K:\TRIALQUOTATIONS\" & Sheets("CUSLIST").Range("A2").Value

Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FolderExists(DirName) Then
MkDir (DirName)
End If
set fs=Nothing
'your code
End Sub

Regards,
Per

"pravin" skrev i meddelelsen
...
1.I wish to create a folder everytime I add a new customer in my customer
list
2.For example, when I add a customer using the FORM under DATA, I enter
the
customer code (eg ABC,BUZ,CKF...), customer name,customer address.The
customer code is in column A, starting at A2
3.For the new customer,by using a micro ,I want to create a new folder
(eg.
"K:\TRIALQUOTATIONS\BUZ") .
4.In future the customer's quotations will be filed in this folder.
5.I had written the following micro, which is giving "run time error 438"

Sub CREATECUSTOMERFOLDER()

ActiveWorkbook.CreateFolder FolderName:="K:\TRIALQUOTATIONS\" &
Sheets("CUSLIST").[A2]
6.Please advise suitable changes in the micro.
End Sub
excelforautomatinginvoicing



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
how to create password for an folder C.M.[_2_] New Users to Excel 1 July 21st 08 11:50 AM
automatically folder create hitesh Excel Discussion (Misc queries) 1 January 2nd 08 11:52 AM
Macro creating folder and files automatically, without permission. pokdbz Excel Discussion (Misc queries) 1 November 8th 07 04:24 PM
Create Folder Using VBA DoooWhat Excel Discussion (Misc queries) 5 September 21st 07 10:28 PM
create folder and save as runandrun Excel Discussion (Misc queries) 10 September 23rd 05 11:40 PM


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