EliseFreedman
Programmer
How do I insert the First Day of Next Month Into a footer automatically
I have got the following code which programatically inserts a footer onto each page of the worksheet and then prompts the user for how many copies are to be printed.
However, the code falls down when it is trying to get the FooterDate. It displays a syntax error. Can anyone see whats wrong. YEAR is highlighted. The same formula works fine when used in a cell
I have got the following code which programatically inserts a footer onto each page of the worksheet and then prompts the user for how many copies are to be printed.
However, the code falls down when it is trying to get the FooterDate. It displays a syntax error. Can anyone see whats wrong. YEAR is highlighted. The same formula works fine when used in a cell
Code:
Private Sub CommandButton1_Click()
Application.EnableEvents = False
Sheets("Pricelist").Select
Application.ActivePrinter = "\\LINDA\Canon iR2200-3300 PCL5e on Ne06:"
Dim NoofCopies As Long
Dim FooterDate As Long
FooterDate = DATE(YEAR(Now()),MONTH(Now())+1,1)
Dim PgCnt As Long
PgCnt = 0
NoofCopies = 0
PgCnt = Application.ExecuteExcel4Macro("Get.Document(50)")
NoofCopies = InputBox("How Many Copies Would You Like To Print", "Blackspur Price Lists")
With ActiveSheet
.PageSetup.LeftFooter = "Updated " & FooterDate
.PageSetup.RightFooter = "&P" ' inserts page number
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=PgCnt, Copies:=NoofCopies, Collate:=True
End With
Cancel = True
Application.EnableEvents = True
End Sub