Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2007

Tip: Looking for answers? Try searching our database.

using VBA when printing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khalil Handal - 24 Mar 2007 21:17 GMT
Hi,
Is there a way to print a sntence (text) in a workbook whenever a print
command is illustrated?
Nick Hodge - 24 Mar 2007 22:27 GMT
Khalil

You could use a workbook_beforeprint() event, like so (It puts I was printed
on [Current date/time] in A1 on Sheet1)

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Sheet1").Range("A1").Value = _
   "I was printed on " & Now()
End Sub

Signature

HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT@zen.co.ukANDTHIS
www.nickhodge.co.uk

> Hi,
> Is there a way to print a sntence (text) in a workbook whenever a print
> command is illustrated?
Khalil Handal - 25 Mar 2007 04:57 GMT
Hi Nick,
I put the code in "Module" after changing the name of the sheet and added
the text in cell A1 but it didn't work. Is this the right place?
To make it more clear:
1-  Cell A1 is not in the printing range (I have selected print area for
each sheet).
2-  I need the sentence for all the sheets in the worbook and not only for
sheet1; in my file the name is "Certificates".
3- This sentence should appear at the bottom of each page on the left side.

In other words:
It might be like having a footer on the left side for anything that is
printed in all the sheets in the workbook.

> Khalil
>
[quoted text clipped - 9 lines]
>> Is there a way to print a sntence (text) in a workbook whenever a print
>> command is illustrated?
Bill Kuunders - 25 Mar 2007 08:02 GMT
Khalil,
Have you tried.....
file
page setup
header/ footer
custom footer
add the sentence in the left part of the footer.

It can be done with vba as Nick Hodge has done
You would need to enter that macro into the "this workbook code" "before
print ".
But you can do that manually for each sheet / book as well.

regards
Bill

> Hi Nick,
> I put the code in "Module" after changing the name of the sheet and added
[quoted text clipped - 24 lines]
>>> Is there a way to print a sntence (text) in a workbook whenever a print
>>> command is illustrated?
Khalil Handal - 25 Mar 2007 08:22 GMT
Hi Bill,
You had an idea about the file I am working with. I will try your
suggestion! the idea was not very clear to me about how to do it (for all
the sheets or even a range).
Khalil

> Khalil,
> Have you tried.....
[quoted text clipped - 40 lines]
>>>> Is there a way to print a sntence (text) in a workbook whenever a print
>>>> command is illustrated?
Nick Hodge - 25 Mar 2007 09:17 GMT
Khalil

This code should go in the ThisWorkbook module not a standard one. To access
it you can right click the small Excel Icon at the upper left of the Excel
window (Not the top one, but the one for the workbook) and select view code.
Paste it in the resulting window. This should fire just before any print
operation for the whole workbook.

This may be better as you add worksheets which will otherwise need to have
the footer added

Signature

HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT@zen.co.ukANDTHIS
www.nickhodge.co.uk

> Hi Nick,
> I put the code in "Module" after changing the name of the sheet and added
[quoted text clipped - 24 lines]
>>> Is there a way to print a sntence (text) in a workbook whenever a print
>>> command is illustrated?
Khalil Handal - 25 Mar 2007 12:41 GMT
Thanks.

Khalil

> Khalil
>
[quoted text clipped - 35 lines]
>>>> Is there a way to print a sntence (text) in a workbook whenever a print
>>>> command is illustrated?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.