ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   File name in the footer/header (https://www.excelbanter.com/excel-discussion-misc-queries/170334-file-name-footer-header.html)

Basharat A. Javaid

File name in the footer/header
 
Is there a way to insert the file name in a footer/header without the ".xls"
in the name?


Basharat.



Gary''s Student

File name in the footer/header
 
Put the following in the Workbook event mcro area:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = ActiveWorkbook.Name
End Sub

--
Gary''s Student - gsnu2007b


"Basharat A. Javaid" wrote:

Is there a way to insert the file name in a footer/header without the ".xls"
in the name?


Basharat.




Dave Peterson

File name in the footer/header
 
And to remove the last 4 characters of the .name:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
dim myName as string
myName = me.name
worksheets("Somesheetnamehere").PageSetup.CenterHe ader _
= right(myname,len(myname)-4)
End Sub

I used the Me keyword--it refers to the object that owns the code. In this
case, it's the workbook that's being printed.

And I only changed a specific worksheet--not the activesheet.

Gary''s Student wrote:

Put the following in the Workbook event mcro area:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = ActiveWorkbook.Name
End Sub

--
Gary''s Student - gsnu2007b

"Basharat A. Javaid" wrote:

Is there a way to insert the file name in a footer/header without the ".xls"
in the name?


Basharat.




--

Dave Peterson


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com