A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

File name in the footer/header



 
 
Thread Tools Display Modes
  #1  
Old December 20th, 2007, 12:00 AM posted to microsoft.public.excel.misc
Basharat A. Javaid
external usenet poster
 
Posts: 5
Default 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.


  #2  
Old December 20th, 2007, 02:22 AM posted to microsoft.public.excel.misc
Gary''s Student
external usenet poster
 
Posts: 7,584
Default 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.



  #3  
Old December 20th, 2007, 12:06 PM posted to microsoft.public.excel.misc
Dave Peterson
external usenet poster
 
Posts: 19,791
Default 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
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


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