I'm trying to save excel files as pdf using vba code and the cutepdf printer. If I do this manually it works, but when I write code it saves the output to a file that cannot be read or opened
Unfortunately I don't have access to the pdfdistiller so can't use this technique which I've seen described in a number of forums.
The code I've used is below. Any help would be gratefully received.
Sub pdfing() Dim cntTrue As Long, cnt As Long Dim rng As Range, bk As Workbook Dim fName As String Dim WB As Workbook Dim FundName As String Workbooks.Open ("S:\SR\QFS\FCW\Names") Range("A1").Select Do FundName = ActiveCell.Value fName = Dir("S:\SR\QFS\" & FundName & ".xls") Do While fName <> "" Workbooks.Open ("S:\SR\QFS\" & fName), UpdateLinks:=0 cnt = cnt + 1 fName = Dir() Application.ScreenUpdating = False Loop ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources Range("A3:X3").Select ActiveWorkbook.Save ActiveWindow.SelectedSheets.PrintOut copies:=1, preview:=False, ActivePrinter:="CutePDF Printer", printtofile:=True, collate:=True, prtofilename:="S:\SR\QFS\" & FundName & ".pdf" Workbooks("Names").Activate ActiveCell.Offset(1, 0).Select Loop Until ActiveCell = "" End Sub