![]() |
making directories
I want to perform the following:
1) prompt the user for a name (input box) 2) create a directory using this name (thisworkbook.path & "\" & name) 3) save this workbook (SaveAs) in this new directory, using the name from the input box Thank you Steve |
making directories
Try this Steve
Sub Test() Dim fs As Object Dim Dirname As String Dim mycell As String mycell = Application.InputBox( _ prompt:="Enter a Dir name", Type:=2) If Trim(mycell) < "" Then Set fs = CreateObject("Scripting.FileSystemObject") Dirname = ThisWorkbook.Path & "\" & Trim(mycell) If Not fs.FolderExists(Dirname) Then fs.CreateFolder Dirname ThisWorkbook.SaveAs Dirname & "\" & Trim(mycell) & ".xls" Else MsgBox "Exist" End If End If End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "steve" wrote in message ... I want to perform the following: 1) prompt the user for a name (input box) 2) create a directory using this name (thisworkbook.path & "\" & name) 3) save this workbook (SaveAs) in this new directory, using the name from the input box Thank you Steve |
making directories
Dim res as String, sName as String
res = Inputbox("Enter the new directory name") if res = "" then exit sub Mkdir Thisworkbook.Path & "\" & res sName = ThisWorkbook.Name Thisworkbook.SaveAs ThisWorkbook.Path & "\" & res & "\" _ & sName or Thisworkbook.SaveAs ThisWorkbook.Path & "\" & res & "\" _ & res & ".xls" depending on what you mean by SaveAs using the name from the inputbox -- Regards, Tom Ogilvy "steve" wrote in message ... I want to perform the following: 1) prompt the user for a name (input box) 2) create a directory using this name (thisworkbook.path & "\" & name) 3) save this workbook (SaveAs) in this new directory, using the name from the input box Thank you Steve |
making directories
Thanks guys,
exactly what i needed, as always "Tom Ogilvy" wrote: Dim res as String, sName as String res = Inputbox("Enter the new directory name") if res = "" then exit sub Mkdir Thisworkbook.Path & "\" & res sName = ThisWorkbook.Name Thisworkbook.SaveAs ThisWorkbook.Path & "\" & res & "\" _ & sName or Thisworkbook.SaveAs ThisWorkbook.Path & "\" & res & "\" _ & res & ".xls" depending on what you mean by SaveAs using the name from the inputbox -- Regards, Tom Ogilvy "steve" wrote in message ... I want to perform the following: 1) prompt the user for a name (input box) 2) create a directory using this name (thisworkbook.path & "\" & name) 3) save this workbook (SaveAs) in this new directory, using the name from the input box Thank you Steve |
All times are GMT +1. The time now is 02:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com