Activeworkbook.saveas Runtime Error 1004
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the runtime error 1004 vba company Business Learn more about hiring developers or posting ads with us Stack Overflow runtime error 1004 excel 2010 Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 runtime error 1004 application-defined or object-defined error million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Run-time error '1004': Method 'SaveAs' of object'_Workbook' failed up vote 0 down vote favorite 1 Users have an Excel runtime error 1004 excel 2013 spreadsheet that when they go to save it, they press a button which runs the below vba code within a macro. The script attempts to save the Excel spreadsheet to a network location amending the file name with today's date. Intermittently the script will fail with "Run-time error '1004': Method 'SaveAs' of object'_Workbook' failed". Does anyone know what the cause is? The script is: Public Sub Copy_Save_R2() Dim wbNew As Workbook Dim fDate
Runtime Error 1004 Method Range Of Object _global Failed
As Date fDate = Worksheets("Update").Range("D3").Value Set wbNew = ActiveWorkbook With wbNew ActiveWorkbook.SaveAs Filename:="Q:\R2 Portfolio Prints\#Archive - R2 Portfolio\" & "R2 Portfolio - CEC A " & Format(fDate, "mm-dd-yyyy") End With Sheets("Update").Activate End Sub excel vba excel-vba share|improve this question edited Aug 21 '15 at 11:17 mielk 3,188517 asked Aug 21 '15 at 11:14 luligoy 111 1 Basically; your code cannot access the mapped drive –Hugo Yates Aug 21 '15 at 11:23 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote As Hugo stated, it could be an issue with the mapped drive. I prefer to use the full UNC path (\Thismachine...), in case the workbook gets used on a machine that doesn't have the mapped drive set up. I thought the missing extension could be the problem, but I just tested it in Excel 2013 and it automatically added .xlsx to the filename. The issue is probably due to the wbNew reference. It's completely unnecessary and should not be combined with ActiveWorkbook. Basically, you should have either a reference to a workbook, or use the predefined ActiveWorkbook reference. I'd also recommend using ThisWorkbook instead, since the user might click on another book while code is running. Public Sub Copy_Save_R2() Dim wbNew As Workbook Dim fDate As Date fDate = Worksheets("Update").Ra
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Runtime Error 1004 Select Method Of Range Class Failed
and policies of this site About Us Learn more about Stack Overflow runtime error 1004 pastespecial method of range class failed the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation runtime error 1004 select method of worksheet class failed Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/32138908/run-time-error-1004-method-saveas-of-object-workbook-failed only takes a minute: Sign up Run-time error '1004' Method 'Save' of object '_Workbook' failed up vote 1 down vote favorite 2 I got this error while running an VBA application. I think this error is related to the following line in my code ActiveWorkbook.Save This is the whole code. LDate = Date LDate = Mid(LDate, 4, 2) If LDate http://stackoverflow.com/questions/18426950/run-time-error-1004-method-save-of-object-workbook-failed > 8 Then Sheets("a").Cells(13, "H").Value = Sheets("a").Cells(13, "H").Value + 1000 Else Sheets("a").Cells(13, "H").Value = Sheets("a").Cells(13, "H").Value + 1 End If ActiveWorkbook.Save Can someone explain the cause of this error and how I can tackle it. Please read below comments. This is the subroutine that is getting executed when the first button is clicked. Sub import() Dim Filt As String Dim FilterIndex As Integer Dim Title As String Dim FileName As Variant Dim finalrow As Integer Dim alldata As String Dim temp As String Dim oFSO As New FileSystemObject Dim oFS As TextStream 'Filt = "Cst Files (*.txt),*.txt" 'Title = "Select a cst File to Import" 'FileName = Application.GetOpenFilename(FileFilter:=Filt, Title:=Title) 'If FileName = False Then 'MsgBox "No File Was Selected" 'Exit Sub 'End If 'Call TestReference ' Open the file dialog Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker) diaFolder.AllowMultiSelect = False diaFolder.Show If diaFolder.SelectedItems.Count <> 0 Then folderpath = diaFolder.SelectedItems(1) folderpath = folderpath & "\" 'MsgBox diaFolder.SelectedItems(1) Set diaFolder = Nothing 'RefreshSheet On Error Resume Next temp = folderpath & "*.txt" sFile = Dir(temp) Do Until sFile = "" inputRow = Sheets("RawData"
Forums Excel Questions run-time error '1004': incorrect function - ActiveWorkbook.SaveAs Results 1 to 8 http://www.mrexcel.com/forum/excel-questions/564771-run-time-error-1004-incorrect-function-activeworkbook-saveas.html of 8 run-time error '1004': incorrect function - ActiveWorkbook.SaveAsThis is https://support.microsoft.com/en-us/kb/292482 a discussion on run-time error '1004': incorrect function - ActiveWorkbook.SaveAs within the Excel Questions forums, part of the Question Forums category; I'm having a strange problem. When I run a VBA script, Excel gives me an error message saying "run-time runtime error error ... 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 Jul 16th, 2011,11:53 AM #1 yky Board Regular Join Date Jun 2011 Posts runtime error 1004 751 run-time error '1004': incorrect function - ActiveWorkbook.SaveAs I'm having a strange problem. When I run a VBA script, Excel gives me an error message saying "run-time error '1004': incorrect function". The strange thing is I repeatedly do everything consistently (open the xlsm, run the script which displays a userform, enter a date, the same date, that is all) and get the error one out of every four times (roughly), not every time. If the problem is due to incorrect function, shouldn't I get the error every time? Even stranger, if I add a msgbox right before the problem code, now, I consistently get the error message "incorrect funcction". Any idea? Thanks. ================================ msgbox("activeworkbook name is " & ActiveWorkbook.Name) ActiveWorkbook.SaveAs Filename:=destinationPath & destinationFileName, FileFormat:= _ xlWorkbookDefault 'where destinationPath is "\\lenovo-pc1\d\deddem\" and 'destinationFileName is "test". I ran the script on lenovo-pc1. Share Share this post on Digg Del.icio.us T
One games Xbox 360 games PC games Windows games Windows phone games Entertainment All Entertainment Movies & TV Music Business & Education Business Students & educators Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Band Microsoft Lumia All Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft