![]() |
VBA Script to Print several named ranges to PDF with cell-defined filenames
I'd like to name several ranges (or define several custom views) an have the VB script print them to PDF using Adobe Acrobat Pro. I thin this can be done by creating a worksheet with a column containing th name of the range/custom view and another column with the desire filename. The sheet would have a "Print" button that triggers th macro. I found a similar script on on another pos (http://tinyurl.com/zjwkx, but don't know how to tweak it for what need. Sub PrintReports() Dim NumberPages, PageNumber, i As Integer Dim ActiveSh As Worksheet Dim ChooseShNameView As String Dim ShNameView As String Application.ScreenUpdating = False Set ActiveSh = ActiveSheet For Each Cell In Range(Range("a2"), Range("a2").End(xlDown)) ShNameView = ActiveCell.Offset(0, 1).Value PageNumber = ActiveCell.Offset(0, 2).Value Select Case Cell.Value Case 1 Sheets(ShNameView).Select Case 2 Application.Goto Reference:=ShNameView Case 3 ActiveWorkbook.CustomViews(ShNameView).Show ActiveWorkbook.CustomViews End Select With ActiveSheet.PageSetup .CenterFooter = PageNumber .LeftFooter = ActiveWorkbook.FullName & "& A &T &D " End With ActiveWindow.SelectedSheets.PrintOut Copies:=1 Next ActiveSh.Select Application.ScreenUpdating = True End Sub Let me know what you think. Thanks -- jbmessamor ----------------------------------------------------------------------- jbmessamore's Profile: http://www.excelforum.com/member.php...fo&userid=3636 View this thread: http://www.excelforum.com/showthread.php?threadid=56148 |
All times are GMT +1. The time now is 05:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com