Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 31st, 2008, 05:29 PM
harshadd's Avatar
Familiar Sight
 
Join Date: Dec 2007
Posts: 163
Default the Workbook_BeforePrint macro

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)

Code:
With xl.ActiveSheet.PageSetup
  .LeftHeader = "&D&T"
  .CenterHeader = ""
  .RightHeader = "&F"
  .LeftFooter = ""
  .CenterFooter = ""
  .RightFooter ="MisAviPivot:Designed & Developed by"  + Chr(10) + "Harshad D. - CorporateIT / "
  .LeftMargin = Application.InchesToPoints(0.75)
  .RightMargin = Application.InchesToPoints(0.50)
  .TopMargin = Application.InchesToPoints(0.75)
  .BottomMargin = Application.InchesToPoints(0.75)
  .HeaderMargin = Application.InchesToPoints(0.5)
  .FooterMargin = Application.InchesToPoints(0.5)
  .PrintHeadings = False
  .PrintGridlines = False
  .PrintComments = xlPrintNoComments
  .PrintQuality = 600
  .CenterHorizontally = False
  .CenterVertically = False
  .Orientation = xlPortrait
  .Draft = False
  .PaperSize = xlPaperA4
  .FirstPageNumber = xlAutomatic
  .Order = xlDownThenOver
  .BlackAndWhite = False
  .Zoom = 100
EndWith
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles