473,569 Members | 2,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the Workbook_Before Print macro

176 New Member
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.
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_Before Print 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.

If any one can guide how do i insert below code in the "Workbook_Befor ePrint" event by using another VB or VFP code (ie programmaticall y)

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 1320

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

Similar topics

by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a clarification on what 'macro' means. A Lisp macro is a way of modifying code when that code is first defined. It can rearrange the structure of the...
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
by: Pete | last post by:
In Access 95/97 I used to be able to create pull down menus (File,Edit ...) from a macro. It seems there used to be some wizard for that. However in Access 2000 it seems you have to build your menus by customizing a toolbar. With this method you have to create a separate macro for every single menu and sub menu. The old method would allow...
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead. Execution is faster. Where will it be stotred?(Is it in bss/stack/?) FUNCTION:
by: Alexander Ulyanov | last post by:
Hi all. Is it possible to pass the whole blocks of code (possibly including " and ,) as macro parameters? I want to do something like: MACRO(FOO, "Foo", "return "Foobar";", "foo(); bar();")
by: lasek | last post by:
Hi...in some posts i've read...something about using macro rather then function...but difference ??. Best regards....
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the Autoexec Macro looks like the way to go. Could someone please assist? Thank you very much! Mike
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record the cursor was on in the datasheet at the time I executed the macro. So, the questions are: 1) In the macro, how to I get my hands on the record...
by: =?Utf-8?B?TGV0emRvXzF0?= | last post by:
I'd like to create a Macro that will sort some raw data, apprx 20k lines, remove some lines based upon a condition in a certain column. Then copy this data into a new spreadsheet and sort the data again and delete the unwanted data and repeat few more times in new sheets. End product will be apprximately 7 or 8 sheets - 1 for Active...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.