ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how can i run macro when i print worksheet. (https://www.excelbanter.com/excel-programming/324125-how-can-i-run-macro-when-i-print-worksheet.html)

shital shah

how can i run macro when i print worksheet.
 
..Hi to all

When i give print command from file menu than only macro has to run. is this
possible.

tnk in advance

****al

Bob Phillips[_6_]

how can i run macro when i print worksheet.
 
****al,

There is a BefdorPrint event availoable which you could add your code to. Go
to the ThisWorkbook code module, select ThisWorkbook from the left dropdown,
and you will find the event in the right dropdown.

--

HTH

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


"****al shah" wrote in message
...
.Hi to all

When i give print command from file menu than only macro has to run. is

this
possible.

tnk in advance

****al




Bill Kuunders

how can i run macro when i print worksheet.
 
Go to VBA editor using <alt + <f11

In the "project - vba project window" double click on "this workbook"
On the right side of the window click on dropdown arrow next to "general"
select "workbook"
click on dropdown arrow next to "open"
select "Beforeprint

enter the name of the macro you want to run without the Sub and without the
( )

So it should look like...........

Private Sub Workbook_BeforePrint(Cancel As Boolean)
macroname
End Sub


Regards
Bill K

"****al shah" wrote in message
...
.Hi to all

When i give print command from file menu than only macro has to run. is
this
possible.

tnk in advance

****al





All times are GMT +1. The time now is 05:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com