Page Header: Setting using InputBox for LeftHeader

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.
 
M

Mark Ivey

InputBox "Get some information.", "Information",
ActiveSheet.PageSetup.LeftHeader



Mark Ivey
 
M

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
 
G

GeraldM

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
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top