I have a workbook with a couple of commandbuttons for saving and printing pdf files. Paul got me fixup
on the SaveAs problem I was having, one more problem. When I save a workbook it becomes that name and then I print out pdf
file. When I save the file it shows up in the print dialog box to save, if I skip the save as button and just want the pdf file I have to type in the name. Here are my two codes,is it possible to have the pdf dialog box show the value in c16 without saving first.
Dim varFullName As Variant
Dim strFileName As String
Cancel = True
strFileName = ThisWorkbook.Sheets("proposal").Range("c16").Value
varFullName = Application.GetSaveAsFilename(InitialFileName:=strFileName, _
fileFilter:="Microsoft Excel Binary Workbook (*.xlsb), *.xlsb")
If varFullName <> Cancel And varFullName <> False Then
On Error GoTo FileNotSaved
Application.EnableEvents = False
ThisWorkbook.SaveAs Filename:=varFullName, FileFormat:=50
Application.EnableEvents = True
End If
Exit Sub
PDF Button Code
Dim DEFprinter As String
'store default printer
DEFprinter = Application.ActivePrinter
Application.ActivePrinter = "CutePDF Writer on CPW2:"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=2, Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", Collate:=True
' change back to default printer
Application.ActivePrinter = DEFprinter
Thanks
Bookmarks