Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default header formatting

I create a header in a work book using

With ActiveSheet.PageSetup
.RightHeader = "&B" & ActiveWorkbook.Name & "&B" & Chr(13) & "&A" &
Chr(13) & "&D" & Chr(13) & "Page &P of &N"
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
ActiveWindow.Zoom = 75
End With

This macro is in file xxx. When the user runs this macro and saves the file
to yyy.xls. I want the first line of the header to be yyy.xls. Currently if
the user runs the macro and saves the file to a different name. The header
is xxx.xls.

What am I missing?
Thanks for any help
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default header formatting

Well I have been reading and this seems to be an issue. On
http://www.j-walk.com/ss/excel/tips/tip22.htm It says that the filename will
not be changed. I am try to use a work around to set the headers before
printing and before save or save as.

The before print works well and the before save is working but is there a
before saveas?

Code below

Tahnks
Mike


Here is what I have:

Function FixHeaders()
Dim wkbk As Workbook
Dim wksht As Worksheet

Set wkbk = ActiveWorkbook
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
sht.Activate
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.RightHeader = "&B" & ActiveWorkbook.Name & "&B" & Chr(13) & "&A" &
Chr(13) & "&D" & Chr(13) & "Page &P of &N"
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
ActiveWindow.Zoom = 75
End With
Next sht
End Function
'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call FixHeaders
End Sub



Private Sub Workbook_BeforePrint(Cancel As Boolean)
Call FixHeaders
End Sub




"quartz" wrote:

Mike,

Try replacing "ActiveWorkbook.Name" with "&F" that may work...

HTH

"Mike" wrote:

I create a header in a work book using

With ActiveSheet.PageSetup
.RightHeader = "&B" & ActiveWorkbook.Name & "&B" & Chr(13) & "&A" &
Chr(13) & "&D" & Chr(13) & "Page &P of &N"
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
ActiveWindow.Zoom = 75
End With

This macro is in file xxx. When the user runs this macro and saves the file
to yyy.xls. I want the first line of the header to be yyy.xls. Currently if
the user runs the macro and saves the file to a different name. The header
is xxx.xls.

What am I missing?
Thanks for any help
Mike

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
header formatting quartz[_2_] Excel Programming 0 December 14th 05 08:19 PM
Header formatting problem ts1 Excel Programming 2 October 28th 05 06:27 PM
Formatting separate lines of header ts1 Excel Programming 3 October 24th 05 03:35 AM
Formatting Codes for header and footer chambers777 Excel Programming 2 January 6th 04 11:50 PM
Formatting a header with VBA universal[_15_] Excel Programming 2 December 10th 03 02:07 PM


All times are GMT +1. The time now is 03:29 AM.

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"