Button - Save Location

R

Ravi Sandhu

Hi guys

I have a file which is a template. This file is read only, and is an Excel
sheet

What I want to do, is place a button on the sheet.

When the button is pressed, a box appears asking for todays day in format:
DD.MM.YYYY (Ideally, if it could automatically set the date, this would be a
bonus.... )

The locationg I want the button to save is: c:/documents/files

How can I do this?
 
L

liddlem

Hi Ravi
I am assuming that your UserForm has a text field called 'TextBox1' an
that it also has a button called 'CommandButton1'.

In the VB Editor, set the UserForm_Initialize to the following.

Private Sub UserForm_Initialize()
Me.TextBox1 = Date
End Sub

Under the CommandButton1 write the following code.

Private Sub CommandButton1_Click()
MyPath = "C:\Documents\Files\" 'Set the Path
MyFileName = "MyName" & UserForm1.TextBox1 & ".xls" 'Create the Fil
Name.
MySaveString = MyPath & MyFileName 'String the two together

ActiveWorkbook.SaveAs Filename:= _
MySaveString, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub


The bit "Activeworkbook.SaveAs........ CreateBackup:=False" wa
recorded using Office XP. (You may need to change this part of the cod
to meet your version of Office requirements
 

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

Top