Text From User Forms

  • Thread starter Thread starter Matt G
  • Start date Start date
M

Matt G

Hi

I am creating a user form where data is entered into text
boxes.

Once the operator has input data into a text box I want to
use a command button on the user form to save the file.

One text box will have a request date entered as the value
and another will have the name of the requestor as the
value. I want the command button to create the filename
as these two values.

Could someone offer some advice please.

Thanks. Matt
 
Matt,

Activeworkbook.SaveAs filename: ="C:\your path\" & Textbox1.Text & " " &
Textbox2.Text

HTH
Henry
 
I created a userform with two textboxes and one commandbutton. The I had this
macro in the commandbutton1_click routine

Option Explicit
Private Sub CommandButton1_Click()
Dim myDate As String
Dim myRequestor As String

myDate = Me.TextBox1.Value
myRequestor = Trim(Me.TextBox2.Value)

If IsDate(myDate) = False Then
MsgBox "Please fix date!"
Me.TextBox1.SetFocus
Exit Sub
End If

If myRequestor = "" Then
MsgBox "please fix name"
Me.TextBox2.SetFocus
Exit Sub
End If

On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=myRequestor & _
"_" & Format(CDate(myDate), "yyyymmdd")
Application.DisplayAlerts = True
If Err.Number <> 0 Then
MsgBox "Not saved!"
Err.Clear
Else
MsgBox "saved"
Unload Me
End If
On Error GoTo 0

End Sub


Don't forget to add the drive and path to the filename:= part.

(also the appliction.displayalerts=false stops the warning if you're overwriting
an existing file.)
 
Back
Top