You are here:

Excel/Excel macro stopped working


this macro is no longer working and i can't debug it.  i am getting a runtime error 1004 document cannot be saved.  it has worked for 2 years.  we have not upgraded excel or changed printing options.  
Do you see an error/change?
When i try to debug the section beginning with bk.Export thru openafterpublish is highlighted.
Thank you

Sub EFT_Receipt()
' EFT_Receipt Macro
' To pdf the customer receipt
' Keyboard Shortcut: Ctrl+r
   ActiveSheet.PageSetup.PrintArea = "$E$2:$G$50"

Dim sh As Worksheet, bk As Workbook
Dim sPath As String
Set sh = ActiveSheet
sPath = "p:\customer service\vanco bestbill services\"
Set bk = ActiveWorkbook
sName = bk.Worksheets(1).Range("F8").Text & ".pdf"
bk.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=sPath & sName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
bk.Close SaveChanges:=False
End Sub


the bk.ExportAsFixedFormat command is provided by the save as PDF addin to the best of my knowledge.  I would guess that the addin is not installed/loaded.  (install/load it)

If it is, then perhaps you path is no longer valid or you have a file with that name already in the specified location.

Tom Ogillvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.