I have some code that will prompt a user to insert their name and the date with an inputbox.
The inputbox will insert the data into the header.
I would like the input box to ask the user to supply info for two places in the left header, one upper most and one lower most, and one place in the right upper. Currently the left lower and right upper is hard coded.
Also the cancel button is not working right.
I looked around and recorded some macros to get to this point but now I’m stuck, any help please is appreciated.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
The inputbox will insert the data into the header.
I would like the input box to ask the user to supply info for two places in the left header, one upper most and one lower most, and one place in the right upper. Currently the left lower and right upper is hard coded.
Also the cancel button is not working right.
I looked around and recorded some macros to get to this point but now I’m stuck, any help please is appreciated.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Code:
[COLOR=black][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]<o:p>Private Sub Workbook_BeforePrint(Cancel As Boolean)[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]'Cancel = True</o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p>Dim strMiddle As String[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]Dim strLeft As String[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]'Dim strRight As String[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Dim i As Integer</o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p>strMiddle = GetInput("your name", "Enter Your Name", Application.UserName)[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]strLeft = GetInput("a date", "The Date", Date)[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]'strRight = GetInput("Weather", "The Weather", Weather)</o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p> With ActiveSheet.PageSetup[/FONT][/COLOR]
[FONT=Courier New][COLOR=black] .LeftHeader = strLeft & Chr(10) & "" & Chr(10) & "Day:_________________"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] .CenterHeader = "&20" + strMiddle[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] .RightHeader = "Weather:_________________"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] </o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p> End With[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]End Sub</o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p>[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]Function GetInput(ByVal strPrompt As String, strTitle As String, strDefault As String) As String</o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p>Dim strInput As Variant</o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]<o:p> Do[/FONT][/COLOR]
[FONT=Courier New][COLOR=black] strInput = ""[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] strInput = Application.InputBox("Please enter " & strPrompt, strTitle, strDefault)[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] Loop While strInput = "" Or strInput = False</o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Courier New]<o:p> GetInput = strInput</o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]<o:p>End Function[/FONT][/COLOR]
[FONT=Courier New][COLOR=black]</o:p>[/COLOR][/FONT]