View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 126
Default How to put in a warning?

Use something like:

If MsgBox("Is the printer ready?", vbYesNo) = vbNo Then
MsgBox "OK. Nothing will be printed"
Exit Sub
End If

For more, check XL VBA help for MsgBox.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Business solutions leveraging technology
Microsoft Most Valuable Professional (MVP) 2000-2004

In article , oswald88
@singnet.com.sg says...

How do I put in a warning in the macro below, like:
"Is the printer ready?" and pause for an answer.
If "yes", macro continues
If "No", abort.

Thank you.

Sub PrintWithPgNumInTitleRow()
Dim NumPages As Long, Pg As Long
NumPages = ExecuteExcel4Macro("Get.document(50)")
ActiveSheet.Range("TotalPages").Value = NumPages
For Pg = 1 To NumPages
With ActiveSheet
.Range("PageNum").Value = Pg
.PrintOut from:=Pg, to:=Pg
End With
Next Pg
End Sub