View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
SunTzuComm SunTzuComm is offline
external usenet poster
 
Posts: 30
Default Prompt user automatically

Hello, gavmer!

Well, actually you do need a little more code to move the text from the input
box to the header or footer. I wasn't sure I should get into that without
knowing how many worksheets are in the workbook or which header/footer you
wanted to change.

Let's assume the workbook contains only one sheet and that you want to modify
the center footer. Here's how that program code would look.

Option Explicit
Public strFooter As String
Private Sub Workbook_Open()
strFooter = InputBox("Please enter the footer:")
ActiveSheet.PageSetup.CenterFooter = strFooter
End Sub

If you wish to modify any other of the headers or footers, just substitute one
of the following keywords for ".CenterFooter" in the above example.

.LeftHeader
.CenterHeader
.RightHeader
.LeftFooter
.RightFooter

If the workbook contains two or more worksheets, you'll have to specify the
name of the one you want to change, as in the following example.

Option Explicit
Public strFooter As String
Private Sub Workbook_Open()
strFooter = InputBox("Please enter the footer:")
Sheets("your worksheet name").PageSetup.CenterFooter = strFooter
End Sub

I hope this explains it better.

Regards,
Wes