I have Created a Userform with two buttons and a couple of text boxes and I would like this form to act similar to a vbyesno msgbox. The problem I am having is that I can't figure out how to make these buttons function without having to put a bunch of if-then statements in a Commandbutton1_click sub. What I would like to do is write a macro in a Module and then call the userform with text and write an if-then statement with the code for the buttons. For Instance:
Sub Filesaveas()
'
' Save Invoice As PDF for Billing Records
'
' Save File
Dim IntialName As String
Dim fileSaveName As Variant
InitialName = Range("F7").Text & "_" & Range("K2") & "_" & Range("F6")
fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitialName, _
FileFilter:="PDF (*.pdf), *pdf")
If fileSaveName <> False Then
UserForm1.Caption = "Save As"
UserForm1.TextBox1.Caption = "Save As:"
UserForm1.TextBox2.Caption = "'" & fileSaveName & "'"
UserForm1.TextBox1.Font.Bold = True
UserForm1.TextBox2.Font.Bold = False
UserForm1.TextBox1.Font.Italic = False
UserForm1.TextBox2.Font.Italic = True
UserForm1.TextBox2.TextAlign = fmTextAlignCenter
UserForm1.TextBox1.TextAlign = fmTextAlignLeft
UserForm1.Show
If 'CommandButton1_Click Here' Then
'Action'
Else
If 'CommandButton2_Click Here' Then
'Action'
End If
End If
End If
End Sub
Bookmarks