PDA

View Full Version : msgBox with a Text Box Input



ironj32
05-16-2007, 07:21 AM
Hi All,
I want to create a msgBox that has an Input Text Box.

I have a button "cmdStartNewVendor". When you click the button I would like a msgBox to appear and ask you to insert the Vendor Name into "txtNewVendor". I am going to do a SaveCopyAs statement. Here is what i have so far. Thanks for your help!


Private Sub cmdStartNewVendor_click()
If MsgBox("Name of New Vendor", vbOKCancel + vbInformation, stTitle) = vbCancel Then
Cancel = True
Else
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & Me.txtNewVendor & ".xls"
End Sub

ironj32
05-16-2007, 07:24 AM
Also I would like to clear the contents of Row 3 in the hidden worksheet, "Saved" in the newly created workbook.

lucas
05-16-2007, 07:32 AM
Altered Steiners (http://vbaexpress.com/kb/getarticle.php?kb_id=119) kb entry slightly:
Private Sub cmdStartNewVendor_click()
Dim Temp$

Temp = InputBox("Name of New Vendor:", "Inputbox")
If StrPtr(Temp) = 0 Then
MsgBox "You pressed Cancel!" 'Option 1
Else
If Temp = "" Then
MsgBox "You entered nothing and pressed OK" ' Option 2
Else
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & Temp & ".xls"
End If
End If
End Sub

ironj32
05-16-2007, 07:38 AM
Awesome Lucas!