I have an excel file with 7 sheets. The first is to receive input values. 2-6 produce printable form letters and 7 has behind the scenes equations and tables.
On sheet one I have a series of check boxes that prompt the user to select which sheets they want printed (sometimes it will be just one, sometimes multiple sheets). These check boxes correspond to TRUE/FALSE values on the last sheet. On sheets 2-6 in cell A1, each has an equation similar to this:
=IF('data_sheet'!A100=TRUE," ",""). This puts a "value" in cell A1. I have a the following macro on the input sheet:
Sub CommandButton1_Click()
Dim Sh As Worksheet
Dim Arr() As String
Dim N As Integer
N = 0
For Each Sh In ActiveWorkbook.Worksheets
If Sh.Visible = xlSheetVisible And Sh.Range("A1").Value <> "" Then
N = N + 1
ReDim Preserve Arr(1 To N)
Arr(N) = Sh.Name
End If
Next
With ActiveWorkbook
.Worksheets(Arr).PrintOut
End With
End Sub
This works fine and prints my selected sheets. We have a program called CutePDF Writer that is setup on system as a printer. When you select this printer, it converts the file into a PDF.
My question is this:
How do I modify the above code to print my selected sheets to "CutePDF Writer on CPW2"?
I have tinkered with the Application.ActivePrinter function with no luck.
disclaimer... I know how to program in C++ but don't know visual basic or understand its syntax, so you need to be specific with your response.
Thanks in advance
Please read the Forum Rules and then edit your post to wrap your code with Code Tags.
I have an excel file with 7 sheets. The first is to receive input values. 2-6 produce printable form letters and 7 has behind the scenes equations and tables.
On sheet one I have a series of check boxes that prompt the user to select which sheets they want printed (sometimes it will be just one, sometimes multiple sheets). These check boxes correspond to TRUE/FALSE values on the last sheet. On sheets 2-6 in cell A1, each has an equation similar to this:
. This puts a "value" in cell A1. I have a the following macro on the input sheet:Code:=IF('data_sheet'!A100=TRUE," ","")
Code:Sub CommandButton1_Click() Dim Sh As Worksheet Dim Arr() As String Dim N As Integer N = 0 For Each Sh In ActiveWorkbook.Worksheets If Sh.Visible = xlSheetVisible And Sh.Range("A1").Value <> "" Then N = N + 1 ReDim Preserve Arr(1 To N) Arr(N) = Sh.Name End If Next With ActiveWorkbook .Worksheets(Arr).PrintOut End With End Sub
This works fine and prints my selected sheets. We have a program called CutePDF Writer that is setup on system as a printer. When you select this printer, it converts the file into a PDF.
My question is this:
How do I modify the above code to print my selected sheets to "CutePDF Writer on CPW2"?
I have tinkered with the Application.ActivePrinter function with no luck.
disclaimer... I know how to program in C++ but don't know visual basic or understand its syntax, so you need to be specific with your response.
Thanks in advance
Last edited by calitopgun; 08-23-2008 at 10:27 PM. Reason: asked to by moderator
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks