472,123 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,123 software developers and data experts.

the Workbook_BeforePrint macro

harshadd
176 100+
Dear friends
I have created an application, which generates a pivot table in excel.
yet there is no problems in module, time came I have to release it to all cities of my organization.
I inserted a code in my module to write headers and footers which will display my name with my department on footers.
It prints this info when a document is printed.
PROBLEM IS HERE:
Some (so called) advance excel users delete the footers before printing the document. and me and my department loos the credit of that report.
So I found the solution that "the Workbook_BeforePrint event" will serve the purpose. But my knowledge allows me to copy paste the code in this place in existing excel file manually.

When my application get released all over country, we do not have control over Excel files created and so can not insert this code this way.

EXPECTED SOLUTION:
If any one can guide how do i insert below code in the "Workbook_BeforePrint" event by using another VB or VFP code (ie programmatically)

Expand|Select|Wrap|Line Numbers
  1. With xl.ActiveSheet.PageSetup
  2.   .LeftHeader = "&D&T"
  3.   .CenterHeader = ""
  4.   .RightHeader = "&F"
  5.   .LeftFooter = ""
  6.   .CenterFooter = ""
  7.   .RightFooter ="MisAviPivot:Designed & Developed by"  + Chr(10) + "Harshad D. - CorporateIT / "
  8.   .LeftMargin = Application.InchesToPoints(0.75)
  9.   .RightMargin = Application.InchesToPoints(0.50)
  10.   .TopMargin = Application.InchesToPoints(0.75)
  11.   .BottomMargin = Application.InchesToPoints(0.75)
  12.   .HeaderMargin = Application.InchesToPoints(0.5)
  13.   .FooterMargin = Application.InchesToPoints(0.5)
  14.   .PrintHeadings = False
  15.   .PrintGridlines = False
  16.   .PrintComments = xlPrintNoComments
  17.   .PrintQuality = 600
  18.   .CenterHorizontally = False
  19.   .CenterVertically = False
  20.   .Orientation = xlPortrait
  21.   .Draft = False
  22.   .PaperSize = xlPaperA4
  23.   .FirstPageNumber = xlAutomatic
  24.   .Order = xlDownThenOver
  25.   .BlackAndWhite = False
  26.   .Zoom = 100
  27. EndWith
Aug 31 '08 #1
0 1278

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

25 posts views Thread by Andrew Dalke | last post: by
699 posts views Thread by mike420 | last post: by
2 posts views Thread by Pete | last post: by
7 posts views Thread by Newbie_sw2003 | last post: by
3 posts views Thread by Alexander Ulyanov | last post: by
8 posts views Thread by lasek | last post: by
6 posts views Thread by Takeadoe | last post: by
reply views Thread by =?Utf-8?B?TGV0emRvXzF0?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.