LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default ByRef Cancel in event module

Hello,

I've gotten in the habit of calling regular procedures from my workbook
event procedures and putting all the working code in the regular subs.
Working on a BeforePrint Procedure, to get it to work I had to set declare
the cancel_print argument ByRef in order to get it to actually cancel the
print job - if I pass it ByVal, Cancel in the event procedure never gets set
to True. Here's a simplified version:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Call wb_bf(Cancel)
End Sub

Sub wb_bf(ByRef cancel_print As Boolean)
If MsgBox("cancel?", vbOKCancel) = vbCancel Then
cancel_print = True
End If
End Sub

I want to know if declaring cancel_print to ByRef is good practice here.
I've gotten the impression that ByRefs are "dangerous." If so, is there a
safer way to do this, like calling a boolean function? Also, the actual
application has3 layers of modules: it starts at the application level class
event, Cancel is passed to an addin, and then to the wb_bf sub.

Thanks,

Doug


 
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
Cannot seem to Cancel EXCEL App Right Click Event using C# Nick Biggs Excel Programming 18 October 28th 09 08:16 AM
Cancel sheet change event NSK Charts and Charting in Excel 1 July 17th 07 08:25 PM
Detecting a cancel on Workbook_BeforeClose event? Don Wiss Excel Programming 3 January 18th 05 12:49 PM
Input Box Cancel Event Craig[_20_] Excel Programming 3 September 7th 04 10:21 AM
Cancel terminate event?? Pop Excel Programming 1 May 19th 04 12:00 PM


All times are GMT +1. The time now is 07:36 PM.

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"