Excel Vba Runtime Error 1004 Document Not Saved
Contents |
Forums Excel Questions "Run-time error '1004'. Document not saved." when exporting to PDF with VBA Page 1 of 2 12 Last Jump to page: Results 1 to excel 2010 vba run time error 1004 document not saved 10 of 12 "Run-time error '1004'. Document not saved." when exporting to PDF excel vba runtime error 1004 application-defined or object-defined error with VBAThis is a discussion on "Run-time error '1004'. Document not saved." when exporting to PDF with VBA within
Excel Vba Runtime Error 1004 Method Range Of Object _global Failed
the Excel Questions forums, part of the Question Forums category; I have a macro that runs from a key combo to save the active worksheet to PDF. It seems that ...
Excel Vba Runtime Error 1004 Method Saveas Of Object _workbook Failed
LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Mar 6th, 2012,12:50 PM #1 sj_robertson New Member Join Date Mar 2010 Posts 7 "Run-time error '1004'. Document not saved." when exporting to PDF with VBA I have a excel vba runtime error 1004 autofilter method of range class failed macro that runs from a key combo to save the active worksheet to PDF. It seems that this macro runs correctly and performs the requested operation (export to PDF), however, it throws up a run-time error, which prevents the macro from completing. Code: Sub ... ... ... .. With ActiveSheet .ExportAsFixedFormat _ Type:=xlTypePDF, _ FileName:="C:\...correct path triple-checked!...\" & Cells(11, 10).Value & "_" & Cells(15, 8).Value & ".pdf", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ OpenAfterPublish:=False ' End With ' Sheets("Sheet1").Delete ' End Sub VBA repeatedly tells me (highlights during Debug) the offending code starts at .ExportAsFixedFormat and ends after OpenAfterPublish:=False, yet I cannot find anything wrong with the coding, despite having corrected the coding and reverted to my original format numerous times. The only thing I can assume is that the underscore in the filename is causing the issue, yet all resources I have checked specify that underscore is a valid character... What is even more confusing is that the macro does produce my final PDF (with the file name in the format CellRef_CellRef); it just fails to delete sheet 1 after doing so... If I then, after deleting S
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 13 Oct 2016 21:11:42 GMT by s_ac5 (squid/3.5.20)
Post your question and get tips & solutions from a community of 418,548 IT Pros & Developers. It's quick & easy. Runtime error 1004 Document Not Saved P: 29 https://bytes.com/topic/excel/answers/950619-runtime-error-1004-document-not-saved rahulwagh Hi, I have written one macro in excel 2010. I am trying http://www.teachexcel.com/excel-help/excel-how-to.php?i=162290 to save the excel file using below code Application.Workbooks(Dir(reportName)).SaveAs Here report name is the compelte path of the file But getting runtime error 1004 Document Not Saved. Please help. Jul 24 '13 #1 Post Reply Share this Question 14 Replies Expert 5K+ P: 8,435 Killer42 I think you have the syntax slightly wrong. According to error 1004 the help, the syntax is: expression.SaveAs(FileName,...) Where expression identifies the workbook you want to save (not the file to save it in). At a guess, that business with Dir() looks as though it probably belongs in the FileName parameter. Jul 24 '13 #2 reply Expert Mod 10K+ P: 12,110 Rabbit You are in the wrong forum. Your thread has been moved to the Excel forum. Ditto on what Killer42 time error 1004 said. But also, you will need to find the correct index for the Workbook. Most likely 0 if that's the only workbook open. Jul 24 '13 #3 reply P: 29 rahulwagh Expression is the object of Excel. For e.g. Excel.Application But I am not creating object instead I am trying Application.Workbooks(Dir(reportName)).Save Purpose to use Dir(reportname) is since there are multiple excel files opened so rather than providing entire path just passing the name of the excel using Dir I am trying to save the excel multiple times. After 3rd it fails. Jul 25 '13 #4 reply Expert 5K+ P: 8,435 Killer42 Ah, I see, you were using Dir() to pick up the file name and using that to select the workbook, instead of referring to it by the index number. Interesting. Also seems a bit risky. Is there anything else in the folder? Also, are you using Save or SaveAs? You've mentioned both. And what's in ReportName? Jul 28 '13 #5 reply Expert Mod 2.5K+ P: 4,994 zmbd Really making this way too complicated: rahulwagh: The function DIR() should NEVER be used in this fashion. It is a low level DOS command intended for use in file IO and manipulations. The fact that you got
Get Your Free Excelebook! Our Top 15 Excel Tutorials Instant Access! E-mail: Download Link: Top 15 Excel Tutorials Excel Tutorials Free Excel Macros Keyboard Shortcuts Excel Forum Contact Subscribe for Free Excel tips & more! E-mail: Advertisements Runtime Error 1004 Document Not Saved Search Excel Forum Posts, Tutorials, Macros, Tips, and More New Excel Help Service! We need your input to help create a new Live Online Excel Help service. Please take our survey and let us know your thoughts! Excel Survey Have a great day!Don Similar Topics | Similar Excel Tutorials | Helpful Excel Macros Runtime Error 1004 Document Not Saved - Excel View Answers Hi, Hope you can help? I am getting an error message in a workbook I recently inherited, "Run-time error 1004 - Document not saved", it appears random cannot spot a pattern. The line of code highlighted is the first line in a macro "ActiveWorkbook.save" Has anyone got any ideas or pointers. Thanks in advance Similar Excel Tutorials Remove Personal Information from Excel Files How to remove all personally identifiable information from an Excel file. When a file is created in Excel, it auto ... Error bars in Charts in Excel How to add, manage, and remove error bars in charts in Excel. Error bars allow you to show the potential variance ... Export an Excel File to a CSV File How to export an Excel file to a CSV file (comma separated values file). This allows you to turn any Excel spread ... Prevent Errors From Appearing in Excel How to prevent errors from appearing in formulas in Excel. This is especially helpful for the Vlookup function. Sec ... Remove Vlookup #N/A Error in Excel How to remove the #N/A error from Vlookup and replace it with a friendly message or a blank cell. Fix the Vlookup ... Print Gridlines in Excel I'll teach you how to show gridlines for Excel when you print your files. This is a neat little feature that will ... Helpful Excel Macros Excel Macro to Save a Specific Worksheet as a New File - This Excel Macro allows you to save a specific worksheet within the Excel Workbook to its own new file. You will b