rcicconetti
New Member
- Joined
- Jan 16, 2016
- Messages
- 34
I have been using the following macro to capture 7 pages of a schedule to pdf. It has worked without issue for quite a while, but now returns an error.
The error occurs at this point:
(PDFranges.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveFileName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True)
It states:
"run-time error '1004'
Document not saved. The document may be open, or an error may have been encountered when saving"
<body id="************" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;"> PDFranges.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveFileName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
</body>
The error occurs at this point:
(PDFranges.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveFileName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True)
It states:
"run-time error '1004'
Document not saved. The document may be open, or an error may have been encountered when saving"
Code:
Sub savetopdf()'
' savetopdf Macro
'
Dim saveFileName As String
Dim PDFranges As Range
With ActiveSheet
saveFileName = CreateObject("WScript.Shell").SpecialFolders("MyDocuments") & .Range("T3").Value & ".pdf"
Set PDFranges = .Range("X3:AC48,AE3:AJ48,AL3:AQ48,AS3:AX48,AA59:AF104,AH59:AM104,AO59:AT104")
End With
PDFranges.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveFileName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
'
End Sub
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
</body>