Page Header: Setting using InputBox for LeftHeader

  • Thread starter Thread starter GeraldM
  • Start date Start date
G

GeraldM

How can I set an InputBox default value to the active worksheet's LeftHeader?

More infor - if needed:
================
I have a workbook with several worksheets.
Each sheet has the same page setup except for the LeftHeader.

Instead of using File>PageSetup on every sheet I select each sheet then run
a macro that uses an InputBox to prompt for the LeftHeader and reset it.

This works OK except the InputBox value is initially <blank>

What I would really like to do is to set the InputBox default value to the
existing LeftHeader value. This way I don't have to re-type the header in
full when, for example, I only want to correct a spelling mistake.
 
InputBox "Get some information.", "Information",
ActiveSheet.PageSetup.LeftHeader



Mark Ivey
 
This should accommodate what you were wanting to do...
(mind the line returns from this post)


getHeader = InputBox("The current left header is shown below. Change as
needed.", "Left Header", ActiveSheet.PageSetup.LeftHeader)

ActiveSheet.PageSetup.LeftHeader = getHeader





Mark Ivey
 
Thanks Mark.

Mark Ivey said:
This should accommodate what you were wanting to do...
(mind the line returns from this post)


getHeader = InputBox("The current left header is shown below. Change as
needed.", "Left Header", ActiveSheet.PageSetup.LeftHeader)

ActiveSheet.PageSetup.LeftHeader = getHeader





Mark Ivey
 
Option Explicit
Sub testme()

Dim myStr As String
Dim myInput As String

myStr = ActiveSheet.PageSetup.LeftHeader

myInput = InputBox(prompt:="Verify the left header", _
Title:="Header", Default:=myStr)

If Trim(myInput) = "" Then
'do nothing, don't clear the header
Else
ActiveSheet.PageSetup.LeftHeader = myInput
End If

End Sub

I don't like Sendkeys, but this worked for me, too:

Option Explicit
Sub testme()
Application.SendKeys "h%c"
Application.Dialogs(xlDialogPageSetup).Show
End Sub
 
Back
Top