Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Setting printer header via code

Hi
I'm running this code below to set the left header on each worksheet in my
activeworkbook with name "Adjustments".
It's working good..but is there a way to set the header to line up with the
left margin?
I have my left and right margins set to 0

Sub PrintHEADERAdjustment()
'Set Print Header on Adjusmtents sheets

Dim sh1 As Excel.Worksheet
Dim sh As Excel.Worksheet
Set sh1 = ActiveWorkbook.ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
If InStr(1, sh.Name, "Adjustments", vbTextCompare) Then
sh.PageSetup.LeftHeader = "&""Arial,Bold""&11" & "Insurance Co: " &
Range("Insurance_Co") & " " & "Policyholder: " & Range("Policyholder") &
Chr(10) & "Policy No: " & Range("Policy_No") & " " & " Period " &
Range("From2") & " " & Range("To2")

End If
Next 'sh

sh1.Activate
Set sh1 = Nothing
Set sh = Nothing

End Sub

Thanks in advance!
Kimberly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Setting printer header via code

Hi Kimberly,

Sorry, don't have an answer for you, but I'd be very interested if one of
the other "gurus" in this forum does.

This has annoyed me for a number of years as regardless of your Page Setup
settings, the position of the header/footer seems to be fixed by Excel. i.e.
0.75" in from the left and 0.75" in from the right.

Regards, Sean.

"KimberlyC" wrote:

Hi
I'm running this code below to set the left header on each worksheet in my
activeworkbook with name "Adjustments".
It's working good..but is there a way to set the header to line up with the
left margin?
I have my left and right margins set to 0

Sub PrintHEADERAdjustment()
'Set Print Header on Adjusmtents sheets

Dim sh1 As Excel.Worksheet
Dim sh As Excel.Worksheet
Set sh1 = ActiveWorkbook.ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
If InStr(1, sh.Name, "Adjustments", vbTextCompare) Then
sh.PageSetup.LeftHeader = "&""Arial,Bold""&11" & "Insurance Co: " &
Range("Insurance_Co") & " " & "Policyholder: " & Range("Policyholder") &
Chr(10) & "Policy No: " & Range("Policy_No") & " " & " Period " &
Range("From2") & " " & Range("To2")

End If
Next 'sh

sh1.Activate
Set sh1 = Nothing
Set sh = Nothing

End Sub

Thanks in advance!
Kimberly



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Setting printer header via code

You can't adjust header/footer margins. If you want to increase the
apparent margin, you can use space characters (using a fixed font like
Courier, you could even calculate the exact margin width).

In article ,
"KimberlyC" wrote:

Hi
I'm running this code below to set the left header on each worksheet in my
activeworkbook with name "Adjustments".
It's working good..but is there a way to set the header to line up with the
left margin?
I have my left and right margins set to 0

Sub PrintHEADERAdjustment()
'Set Print Header on Adjusmtents sheets

Dim sh1 As Excel.Worksheet
Dim sh As Excel.Worksheet
Set sh1 = ActiveWorkbook.ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
If InStr(1, sh.Name, "Adjustments", vbTextCompare) Then
sh.PageSetup.LeftHeader = "&""Arial,Bold""&11" & "Insurance Co: " &
Range("Insurance_Co") & " " & "Policyholder: " & Range("Policyholder") &
Chr(10) & "Policy No: " & Range("Policy_No") & " " & " Period " &
Range("From2") & " " & Range("To2")

End If
Next 'sh

sh1.Activate
Set sh1 = Nothing
Set sh = Nothing

End Sub

Thanks in advance!
Kimberly

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Setting printer header via code

I think the only way you can align headers is by adding filler characters (and
it doesn't usually match up perfect (for me anyway)).

Leading spaces are easy, but for trailing spaces, the last character can be the
HTML non-breaking space hit and hold the alt-key while typing 0160 on the
numeric keypad.

(Excel likes to just chop regular trailing spaces.)

===========

Ps. if those ranges (range("policyholder") are sheet level names, maybe you
should qualify them:

sh.range("policyholder").value

(I like .value, too!)

KimberlyC wrote:

Hi
I'm running this code below to set the left header on each worksheet in my
activeworkbook with name "Adjustments".
It's working good..but is there a way to set the header to line up with the
left margin?
I have my left and right margins set to 0

Sub PrintHEADERAdjustment()
'Set Print Header on Adjusmtents sheets

Dim sh1 As Excel.Worksheet
Dim sh As Excel.Worksheet
Set sh1 = ActiveWorkbook.ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
If InStr(1, sh.Name, "Adjustments", vbTextCompare) Then
sh.PageSetup.LeftHeader = "&""Arial,Bold""&11" & "Insurance Co: " &
Range("Insurance_Co") & " " & "Policyholder: " & Range("Policyholder") &
Chr(10) & "Policy No: " & Range("Policy_No") & " " & " Period " &
Range("From2") & " " & Range("To2")

End If
Next 'sh

sh1.Activate
Set sh1 = Nothing
Set sh = Nothing

End Sub

Thanks in advance!
Kimberly


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Setting printer header via code

Thank you all for your help.. I'll just center the headers and move on ! :)

"KimberlyC" wrote in message
...
Hi
I'm running this code below to set the left header on each worksheet in my
activeworkbook with name "Adjustments".
It's working good..but is there a way to set the header to line up with

the
left margin?
I have my left and right margins set to 0

Sub PrintHEADERAdjustment()
'Set Print Header on Adjusmtents sheets

Dim sh1 As Excel.Worksheet
Dim sh As Excel.Worksheet
Set sh1 = ActiveWorkbook.ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
If InStr(1, sh.Name, "Adjustments", vbTextCompare) Then
sh.PageSetup.LeftHeader = "&""Arial,Bold""&11" & "Insurance Co: " &
Range("Insurance_Co") & " " & "Policyholder: " & Range("Policyholder") &
Chr(10) & "Policy No: " & Range("Policy_No") & " " & " Period " &
Range("From2") & " " & Range("To2")

End If
Next 'sh

sh1.Activate
Set sh1 = Nothing
Set sh = Nothing

End Sub

Thanks in advance!
Kimberly






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
Default printer setting John Excel Discussion (Misc queries) 1 March 22nd 07 03:20 PM
Printer Multiple Worksheets with a particular Printer Setting PP[_2_] Excel Worksheet Functions 0 March 14th 07 02:02 PM
Setting default printer using wsh PO Excel Programming 3 February 14th 05 07:09 PM
Setting Printer Nathan[_4_] Excel Programming 4 June 23rd 04 05:36 PM
Setting printer paper smi Excel Programming 3 October 19th 03 08:59 PM


All times are GMT +1. The time now is 04:21 PM.

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

About Us

"It's about Microsoft Excel"