Hidden Dan
Board Regular
- Joined
- Dec 7, 2016
- Messages
- 63
Hello,
I create some Word / Excel documents which are combined into 1 PDF. No problem at all here.
However, I struggle with pagination of the Excel part. Depending on last page of Word document the Excel must start with a certain number. This can be any number like 30, 40 or 43. The Excel itself consists of 30-40 different sheets, each representing 1 single page. Also, the Excel needs header and footers which are now hard coded by a VBA script.
The script I use was found elsewhere and is called 'xlStdHeaderFooter'. It has a pagination option for the RightFooter. But this works fine if you start with Page 1. But I'm currently looking for an addition that seeks for the starting page number. This starting page number can be found on a sheet called 'Config', which basically contains all kind of generic information regarding the spreadsheet.
Say, starting page number is 40 and can be found in cell F8 on sheet 'Config'.
Please find below the script which is placed in 'ThisWorkbook'.
I'm sorry for the explanation but I hope it makes my problem clear.
Thank you for any help.
I create some Word / Excel documents which are combined into 1 PDF. No problem at all here.
However, I struggle with pagination of the Excel part. Depending on last page of Word document the Excel must start with a certain number. This can be any number like 30, 40 or 43. The Excel itself consists of 30-40 different sheets, each representing 1 single page. Also, the Excel needs header and footers which are now hard coded by a VBA script.
The script I use was found elsewhere and is called 'xlStdHeaderFooter'. It has a pagination option for the RightFooter. But this works fine if you start with Page 1. But I'm currently looking for an addition that seeks for the starting page number. This starting page number can be found on a sheet called 'Config', which basically contains all kind of generic information regarding the spreadsheet.
Say, starting page number is 40 and can be found in cell F8 on sheet 'Config'.
Please find below the script which is placed in 'ThisWorkbook'.
VBA Code:
Sub xlStdFooter()
'
'****************************************************************************************
' Title xlStdFooter
' Target Application: MS Excel
' Function: builds standard Excel footer
' a call to this subroutine is added to the Workbook_BeforePrint proc
' in the "ThisWorkbook" code module
'
'****************************************************************************************
'
'
ActiveSheet.PageSetup.LeftFooter = _
"File: " & ActiveWorkbook.Name & vbLf & _
"Tab: " & ActiveSheet.Name
ActiveSheet.PageSetup.CenterFooter = _
"Date Printed: " & Format(Date, "dd-mmm-yyyy") & vbLf & _
"Time Printed: " & Format(Time, "hhmm") & " hrs"
ActiveSheet.PageSetup.RightFooter = _
"Page #: " & "&P" & vbLf & _
"Total Pages: " + "&N"
End Sub
I'm sorry for the explanation but I hope it makes my problem clear.
Thank you for any help.