VBA Script to Print several named ranges to PDF with cell-defined filenames

J

jbmessamore

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
 

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