Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry - lost my original post _
Have a macro that creates a workbook, copies som sheets from various other books, then loops thru all sheets, creating a header fro each. For some unknown reason, my header is only appearing in about half of my sheets, even tough my procedure is hitting and running the following code for each sheet in my book, I have run this code on other books and it seems to work. This is the latest version of the several slight variations of code that I have tried to run. Any one PLEASE PLEASE have any possible ideas as to what my problem is ? Thanks in advance for any help - SeanMc Public Sub HeaderSet() Dim sht As Worksheet For Each sht In Workbooks(s_Author & ".xls").Sheets If sht.Type = xlWorksheet Then sht.Activate MsgBox ActiveSheet.Name ActiveSheet.PageSetup.LeftHeader = _ "Page No. " & "&P" & " of &N" ActiveSheet.PageSetup.CenterHeader = _ s_Author & Chr(10) & "&F" & Chr(10) & "&A" ActiveSheet.PageSetup.RightHeader = "&D" End If Next sht End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "What-A-Tool" wrote in message ... Sorry - lost my original post _ Have a macro that creates a workbook, copies som sheets from various other books, then loops thru all sheets, creating a header fro each. For some unknown reason, my header is only appearing in about half of my sheets, even tough my procedure is hitting and running the following code for each sheet in my book, I have run this code on other books and it seems to work. The strange thing is, when I PRINT PREVIEW, and click SETUP, then click the HEADER/FOOTER tab, the correct header is displayed, even for the sheets that don't display it in PRINT PREVIEW. (It doesn't print on hard copies, either) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() You are printing three lines in the center header. Are the header margins large enough to accommodate that? Also, the first two lines in the center header are almost identical. It appears you could eliminate the first line. For what its worth, here is a little more efficient version of the code... Public Sub HeaderSet() Dim sht As Worksheet Dim s_Author As String s_Author = "Fill in the Name" '<<<< For Each sht In Workbooks(s_Author & ".xls").Worksheets ' MsgBox sht.Name sht.PageSetup.LeftHeader = "Page No. " & "&P" & " of &N" sht.PageSetup.CenterHeader = "&F" & Chr(10) & "&A" sht.PageSetup.RightHeader = "&D" Next sht End Sub Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "What-A-Tool" wrote in message The strange thing is, when I PRINT PREVIEW, and click SETUP, then click the HEADER/FOOTER tab, the correct header is displayed, even for the sheets that don't display it in PRINT PREVIEW. (It doesn't print on hard copies, either) |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Jim Cone" wrote in message ... You are printing three lines in the center header. Are the header margins large enough to accommodate that? Also, the first two lines in the center header are almost identical. It appears you could eliminate the first line. For what its worth, here is a little more efficient version of the code... Public Sub HeaderSet() Dim sht As Worksheet Dim s_Author As String s_Author = "Fill in the Name" '<<<< For Each sht In Workbooks(s_Author & ".xls").Worksheets ' MsgBox sht.Name sht.PageSetup.LeftHeader = "Page No. " & "&P" & " of &N" sht.PageSetup.CenterHeader = "&F" & Chr(10) & "&A" sht.PageSetup.RightHeader = "&D" Next sht End Sub Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "What-A-Tool" wrote in message The strange thing is, when I PRINT PREVIEW, and click SETUP, then click the HEADER/FOOTER tab, the correct header is displayed, even for the sheets that don't display it in PRINT PREVIEW. (It doesn't print on hard copies, either) Thanks Jim. Not much diffferent than what I have. Still doesn't make a difference, though. I tried putting in just the strings "a", "b", and "c" for the 3 different alignments and get the same result(or lack thereof). |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "What-A-Tool" wrote in message ... Sorry - lost my original post _ Have a macro that creates a workbook, copies som sheets from various other books, then loops thru all sheets, creating a header fro each. For some unknown reason, my header is only appearing in about half of my sheets, even tough my procedure is hitting and running the following code for each sheet in my book, I have run this code on other books and it seems to work. Simple solution that for some reason just wasn't registering ! The sheets that my header wasn't showing up on had a TOP MARGIN of .5in The sheets that it was working on had a TOP MARGIN of 1.25in All works fine with a simple edition to my AddHeader Procedure : sht.PageSetup.TopMargin = Application.InchesToPoints(1.25) Thanks Tom and Jim for taking the time to try and help - Sean |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I duplicate headers and footers on multiple sheets? | Excel Worksheet Functions | |||
vba : Headers not displaying in all sheets | Excel Programming | |||
how do i change headers on all workbook sheets globally? | Excel Discussion (Misc queries) | |||
Macro turning colums w/headers into list on multiple sheets | Excel Programming | |||
how do I copy excel sheets with headers | Excel Worksheet Functions |