View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
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