Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Print From Macro Only

I want to restrict the users from using the file/print and only be able to
print from a macro. I saw this somewhere where you disable the print before
and only allow the user to print from a macro.

I can not find it. It went something like setting a global varible I think.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Print From Macro Only

There is a BeforePrint event where you can test a global variable which you
set in code

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Not fFromCode Then
Cancel = True
fFromCode = False
End If
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pete" wrote in message
...
I want to restrict the users from using the file/print and only be able to
print from a macro. I saw this somewhere where you disable the print

before
and only allow the user to print from a macro.

I can not find it. It went something like setting a global varible I

think.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Print From Macro Only

Small error

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Not fFromCode Then
Cancel = True
End If
fFromCode = False
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...
There is a BeforePrint event where you can test a global variable which

you
set in code

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Not fFromCode Then
Cancel = True
fFromCode = False
End If
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pete" wrote in message
...
I want to restrict the users from using the file/print and only be able

to
print from a macro. I saw this somewhere where you disable the print

before
and only allow the user to print from a macro.

I can not find it. It went something like setting a global varible I

think.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Print From Macro Only

Hi Pete

Place the following code in the "ThisWorkBook" module....
Private Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox "Please use the 'PrintActiveSheet' macro"
Cancel = True
End Sub

Place the following code in a general module....
Sub PrintActiveSheet()
Application.EnableEvents = False
ActiveSheet.PrintOut
Application.EnableEvents = True
End Sub

To print the active sheet run the "PrintActiveSheet" macro.
--

-----
XL2003
Regards

William



"Pete" wrote in message
...
I want to restrict the users from using the file/print and only be able to
print from a macro. I saw this somewhere where you disable the print
before
and only allow the user to print from a macro.

I can not find it. It went something like setting a global varible I
think.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Print From Macro Only

Bob...

What version of Excel is that event first introduced?

"Bob Phillips" wrote:

There is a BeforePrint event where you can test a global variable which you
set in code

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Not fFromCode Then
Cancel = True
fFromCode = False
End If
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pete" wrote in message
...
I want to restrict the users from using the file/print and only be able to
print from a macro. I saw this somewhere where you disable the print

before
and only allow the user to print from a macro.

I can not find it. It went something like setting a global varible I

think.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Print From Macro Only

xl97.

Jim Thomlinson wrote:

Bob...

What version of Excel is that event first introduced?

"Bob Phillips" wrote:

There is a BeforePrint event where you can test a global variable which you
set in code

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Not fFromCode Then
Cancel = True
fFromCode = False
End If
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pete" wrote in message
...
I want to restrict the users from using the file/print and only be able to
print from a macro. I saw this somewhere where you disable the print

before
and only allow the user to print from a macro.

I can not find it. It went something like setting a global varible I

think.




--

Dave Peterson
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
print button macro & specific tabs to print Chuck[_3_] Excel Worksheet Functions 2 November 22nd 07 12:21 AM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Macro to open print window and set to print entire workbook retseort Excel Discussion (Misc queries) 1 October 27th 05 11:00 PM
Create a print macro that would automatically select print area? wastedwings Excel Worksheet Functions 7 August 22nd 05 10:36 PM
Need Help w/ Print Macro to Print All Visible Sheets (including Charts) in a Workbook will Excel Programming 3 September 23rd 04 08:05 PM


All times are GMT +1. The time now is 11:41 PM.

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

About Us

"It's about Microsoft Excel"