Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to put in a warning?


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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How to put in a warning?

Dim Resp as long

resp = msgbox(prompt:="Really print?", buttons:=vbyesno)
if resp = vbno then
exit sub
end if

Right near the top of your code??


Teak wrote:

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


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default How to put in a warning?

Another solution is to put the printer dialog for the user to determine what happend next--not easy to determine if the printer is ready unless it is next to the PC

Application.Dialogs(xlDialogPrint).Show

If this returns true, the user clicked OK i.e. print else the return value is false i.e. the user clicked Cancel. In adition to this, the user can
select the target printer (why always use the default?),
specify the number of copies etc.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to put in a warning?

If you have the appropriate software (VB or the developer version of
Office XP or later), you can create a COM add-in. Of course, it will
only work with Office 2000 or later.

--
Regards,

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

In article ,
says...
Hi All

Is there any way to protect the program (my VBA program) other than use
password, like in Ms Access, we can "compile" them? As we know using
password is not too safe, we can find the password crack from internet?
Pls give any comment!
TIA

Yanto



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get rid of the warning message RJ Setting up and Configuration of Excel 2 March 27th 09 05:35 PM
Warning Messages fabio Excel Worksheet Functions 3 October 15th 08 10:54 AM
Pop up warning Michael Excel Discussion (Misc queries) 0 January 16th 08 04:02 PM
warning box delete automatically Excel Worksheet Functions 3 October 20th 07 03:31 PM
Warning!!! Paul Excel Worksheet Functions 6 August 2nd 05 05:58 PM


All times are GMT +1. The time now is 04:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"