ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   creating new folder while saving document (https://www.excelbanter.com/excel-programming/301801-creating-new-folder-while-saving-document.html)

dok112[_9_]

creating new folder while saving document
 
I am trying to create a command, that when clicked will print out a boo
twice and save it. It needs to create a new folder in the directory.
The Name of the folder, needs to be what is in Text Box 1. This i
what I currently have. Can someone point me in the right direction?


Private Sub CommandButton1_Click()
Unload Me
ActiveWorkbook.PrintOut
ChDir "\\Pkcfp009\Mait_e&d\NewHireDocumentation\La
Forms\Transition to Success\"
Dim NameOFile$
NameOFile = TextBox2.Text
ThisWorkbook.SaveAs NameOFile & ".xls"
ChDir "%USERPROFILE%\Transition to Success Plans\"
Dim NameOFile$
NameOFile = TextBox2.Text
ThisWorkbook.SaveAs NameOFile & ".xls"
End Su

--
Message posted from http://www.ExcelForum.com


dok112[_10_]

creating new folder while saving document
 
Also,

When it saves it, it is not saving the actual excel workbook. It i
renaming the userform and saving that. How do I tell it to save th
file that it was sending the info to. I've tried calling up th
workbook then saving it, but it still doesnt work

--
Message posted from http://www.ExcelForum.com


Auric__

creating new folder while saving document
 
On Thu, 17 Jun 2004 21:49:41 -0500, dok112
wrote:

I am trying to create a command, that when clicked will print out a book
twice and save it. It needs to create a new folder in the directory.
The Name of the folder, needs to be what is in Text Box 1. This is
what I currently have. Can someone point me in the right direction?


Private Sub CommandButton1_Click()
Unload Me
ActiveWorkbook.PrintOut
ChDir "\\Pkcfp009\Mait_e&d\NewHireDocumentation\Lab
Forms\Transition to Success\"
Dim NameOFile$
NameOFile = TextBox2.Text
ThisWorkbook.SaveAs NameOFile & ".xls"
ChDir "%USERPROFILE%\Transition to Success Plans\"
Dim NameOFile$
NameOFile = TextBox2.Text
ThisWorkbook.SaveAs NameOFile & ".xls"
End Sub


Okay, so, TextBox1 is the new folder, and TextBox2 is a new filename?
How about this:
newFolder$ = "full\path\to\new\folder\" & TextBox1.Text
MkDir newFolder$
newFile$ = newFolder$ & "\" & TextBox2.Text & ".xls"
ThisWorkbook.SaveAs newFile$

--
auric underscore underscore at hotmail dot com
*****
Sweet Virgin Mary's tampon!

dok112[_13_]

creating new folder while saving document
 
This works great!! Only problem, it is saving the userform file, no
the actual document. Basically, I am using a userform to inser
information multiple times in a .xls file. When it's done, I need t
save it the file (TextBox2.Text) and the filename (TextBox1.Text). Bu
I need to save the document, not the userfile. How do I do this

--
Message posted from http://www.ExcelForum.com


Auric__

creating new folder while saving document
 
On Mon, 21 Jun 2004 09:40:24 -0500, dok112
wrote:

This works great!! Only problem, it is saving the userform file, not
the actual document. Basically, I am using a userform to insert
information multiple times in a .xls file. When it's done, I need to
save it the file (TextBox2.Text) and the filename (TextBox1.Text). But
I need to save the document, not the userfile. How do I do this?


So, instead of giving you a .xls file, you're getting a .frm file? If
so, that's... weird... I didn't know you could do that... As for solving
that, beats the heck outta me.
--
auric underscore underscore at hotmail dot com
*****
Caffeine makes the world go round.


All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com