PDA

View Full Version : Create PDF Stopped Working.... Help!



sm789
07-14-2012, 12:53 AM
I have a macro that saves a range of the worksheet as two separate PDFs. It has been working fine for several months. From last week suddenly it has started sending the document to the printer instead of saving them as PDF. Nothing has changed. Can anyone help? The relevant part of the code is as follows:


‘Start Code for creating PDF

‘ForSavingPDF is a defined range

Application.Goto Reference:="ForSavingPDF"

' Retrieve settings for File Name and Location

WhereTo1 = Range("S67").Value
WhereTo2 = Range("T67").Value
Stamp = Range("C68").Value

' Check if Stamp-field has any value at all, if not, add the current date.
If Stamp = "" Then Stamp = Date

' Assemble the filename
sFileName1 = WhereTo1 & Stamp & y & ".pdf"

' Save the Files as PDF

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=sFileName1, Quality _
:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

' Assemble the second filename
sFileName2 = WhereTo2 & Stamp & y & ".pdf"


' Check if the File Already Exists - There is a problem with the below line - need to resolve. LESS CRITICAL BUT IF YOU CAN HELP, WILL APPRECIATE VERY MUCH!


If Dir(sFileName2) = "" Then
GoTo SaveFile2:

Else
End If

Select Case MsgBox("This file exists. Continue & overwrite?", vbYesNo Or _
vbExclamation Or vbDefaultButton1, "")
Case vbYes
GoTo SaveFile2:

Case vbNo
GoTo Continue:
End Select

SaveFile2:
‘ I deliberately keep a different method of creating the second PDF for future reference.

Range("ForSavingPDF ").ExportAsFixedFormat Type:=xlTypePDF, FileName:=sFileName2

' End of PDF creation

Continue:[/FONT]


The part where it checks if the file exists or not is also not working but right now this is not critical for me. I can REM it out and create my PDFs. Whenever I run this macro, it sends two print jobs to the printer.

Thank you,
SM