Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Headers and Footers in VBA

I use Excel 2002. I recently got info from this group about printing headers
and footers on selected pages, and it worked very well. Now my question is;
How do I specify a multi line header (of footer), in a format similar to an
address, ie:

Name
Street address
City, State
Zip Code

I have not been able to find code to force a Carriage Return.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Headers and Footers in VBA

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.LeftHeader = "Line 1" & vbCr & "Line 2"
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JacMar" wrote in message
...
I use Excel 2002. I recently got info from this group about printing

headers
and footers on selected pages, and it worked very well. Now my question

is;
How do I specify a multi line header (of footer), in a format similar to

an
address, ie:

Name
Street address
City, State
Zip Code

I have not been able to find code to force a Carriage Return.

Thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Headers and Footers in VBA

Thanks Bob Phillips: this helped a lot. But I have now discovered a couple
other problems: The setup is as follows: I have a logo (picture) to print
as a left header. It works. Then I want to print the complete address, to
the right of that left header. I tried to use CenterHeader for that. But it
prints the multi lines of text with a "center" format. I'd like it to be
left justified. If I use "&L", it justifies it to the left of the sheet of
paper, and writes over the logo. I thought that LeftHeader, CenterHeader and
Right Header divided the page in three seperate regions. It seems not.

How can I left justify multiline text, to the right of my LeftFooter logo?

I would also like to add text (Annex "X" to Contract "Y" for example), under
the picture logo, left justified to the page. If I use LeftHeader, it writes
it top left and the picture logo dissappears. If I use CenterHeader, put a
bunch of blank lines and then asks that the text be left justified, it
overwrites the logo on the top left, seemingly ignoring the blank lines.

How do I do it.

Thanks again, you have all been very helpful

"Bob Phillips" wrote:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.LeftHeader = "Line 1" & vbCr & "Line 2"
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JacMar" wrote in message
...
I use Excel 2002. I recently got info from this group about printing

headers
and footers on selected pages, and it worked very well. Now my question

is;
How do I specify a multi line header (of footer), in a format similar to

an
address, ie:

Name
Street address
City, State
Zip Code

I have not been able to find code to force a Carriage Return.

Thanks in advance




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Headers and Footers in VBA

On the first point, text in the centre heading area is centred, and I don't
know how to avoid that.

Perhaps you could put the address in the left header and the picture centred
or right, or put the address in the right header, it will be right aligned,
but that won't be as bad as centre aligned.

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JacMar" wrote in message
...
Thanks Bob Phillips: this helped a lot. But I have now discovered a

couple
other problems: The setup is as follows: I have a logo (picture) to

print
as a left header. It works. Then I want to print the complete address,

to
the right of that left header. I tried to use CenterHeader for that. But

it
prints the multi lines of text with a "center" format. I'd like it to be
left justified. If I use "&L", it justifies it to the left of the sheet

of
paper, and writes over the logo. I thought that LeftHeader, CenterHeader

and
Right Header divided the page in three seperate regions. It seems not.

How can I left justify multiline text, to the right of my LeftFooter logo?

I would also like to add text (Annex "X" to Contract "Y" for example),

under
the picture logo, left justified to the page. If I use LeftHeader, it

writes
it top left and the picture logo dissappears. If I use CenterHeader, put

a
bunch of blank lines and then asks that the text be left justified, it
overwrites the logo on the top left, seemingly ignoring the blank lines.

How do I do it.

Thanks again, you have all been very helpful

"Bob Phillips" wrote:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.LeftHeader = "Line 1" & vbCr & "Line 2"
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"JacMar" wrote in message
...
I use Excel 2002. I recently got info from this group about printing

headers
and footers on selected pages, and it worked very well. Now my

question
is;
How do I specify a multi line header (of footer), in a format similar

to
an
address, ie:

Name
Street address
City, State
Zip Code

I have not been able to find code to force a Carriage Return.

Thanks in advance






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Headers and Footers in VBA

Thanks. Actually, plan B was to put the address as a RightHeader. How about
my second question: where I have not been able to put text under the picture
logo? Because the data in this text will change, I cannot incorporate it in
the picture logo. Any suggestions?

Thanks again

"Bob Phillips" wrote:

On the first point, text in the centre heading area is centred, and I don't
know how to avoid that.

Perhaps you could put the address in the left header and the picture centred
or right, or put the address in the right header, it will be right aligned,
but that won't be as bad as centre aligned.

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I save custom headers and footers to use in other files? Gcwensel Excel Worksheet Functions 1 July 15th 09 02:57 PM
How do you protect Headers and Footers in MOFFICE Tommydraw123 Excel Worksheet Functions 0 October 31st 06 03:13 PM
Copy Headers and Footers between wookbooks Dave Excel Discussion (Misc queries) 1 May 6th 06 03:47 PM
headers and footers Tester Excel Discussion (Misc queries) 2 November 16th 05 12:58 AM
Pre-set headers and footers for new worksheets robertwesley Excel Discussion (Misc queries) 4 April 27th 05 11:14 AM


All times are GMT +1. The time now is 09:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"