Hey everybody,
I had another thread going regarding this issue but it is not yet resolved. Could someone please look at this and give advice. What I want to do is this, when someone hits the ActiveX button for printing the letter on the sheet "DONATION LETTER", I want a message box to come up that asks if they want to print an envelope with the letter. If they say no, it just prints the letter, which works fine. If they say yes, I want to pause the macro, and bring up an InputBox for the user to enter a name and address to put on the envelope in a Text box that is on the worksheet "ENVELOPE" and then print the letter and the envelope. The problem that I am having, aside from the fact that I am new to VBA and this is my first time using InputBox is that this code keeps bringing up errors. Thanx for your time, I know it is valuable.
[VBA]
Dim Msg, Style, Title, Response, myString
Dim myRange, Cell As Range
Msg = "Would you like to print an envelope with this letter?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "PRINT DONATION LETTER"
Response = MsgBox(["Would you like to print an envelope with this letter?"], _
vbYesNo + vbQuestion + vbDefaultButton1, ["PRINT DONATION LETTER"])
myString = "Yes" + "No"
If Response = vbYes Then
Sheets("ENVELOPE").Activate
Range("F13:K19").Select
myString = ""
Set myRange = Range("F13:K19")
For Each Cell In myRange
myString = Cell.Value
InputBox = Me.TextBox.Text = myString
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("ENVELOPE").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Protect Structure:=True, Windows:=False
Sheets("DONATION LETTER").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Protect Structure:=True, Windows:=False
Range("A1").Select
ElseIf Response = vbNo Then
Sheets("DONATION LETTER").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Protect Structure:=True, Windows:=False
Range("A1").Select
End If
End Sub
[/VBA]
Thanx Scott