creating new folder while saving document

D

dok112

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
 
D

dok112

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
 
A

Auric__

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$
 
D

dok112

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
 
A

Auric__

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Saving File automatically 2
userform delete sheet 2
Macro Saving 1

Top