+ Reply to Thread
Results 1 to 6 of 6

Run time error 1004 and i cant figure out why??

Hybrid View

  1. #1
    Registered User
    Join Date
    09-25-2014
    Location
    denver co
    MS-Off Ver
    2013
    Posts
    5

    Exclamation Run time error 1004 and i cant figure out why??

    hey everybody.
    Okay so Im having issues with trying to save my invoice sheet as a new workbook. i have got it so i can change my invoice number since its just invoices. but when i try and run a macro that is supposed to save the sheet as a new workbook it comes up with runtime error 1004 and tells me to check a bunch of stuff and after going through it all i cant figure it out. please help me out.

    p.s. this is the code im using and the bold part is what gets highlighted when i debug.
    Sub SaveInvWithNewName()
        Dim NewFN As Variant
        Dim sfile As String
        ' Copy Invoice to a new workbook
        ActiveSheet.Copy
        NewFN = "C:\Users\Owner\Documents\roof_invoices\" & Range("A14").Value & ".xlsx"
        ActiveWorkbook.SaveAs NewFN, FileFormat:=xlExcel8
        ActiveWorkbook.Close
    End Sub
    Last edited by vmandonado; 10-02-2014 at 12:52 AM.

  2. #2
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Run time error 1004 and i cant figure out why??

    Hi,

    Try this and hope this will help:

    Sub save()
    ActiveWorkbook.SaveAS Filename:=NewFN, FileFormat:= _
      xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
     , CreateBackup:=False
    End Sub
    Last edited by Fotis1991; 10-02-2014 at 02:53 AM. Reason: Also pls use code tags around your codes!
    Click on "* Add Reputation" as a way to say thanks

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Run time error 1004 and i cant figure out why??

    pareshj

    Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore requests by Administrators, Moderators and senior forum members regarding forum rules.

    If you are unclear about the request or instruction then send a private message to them asking for clarification.

    All participants:
    Please do not post a reply in a thread where a moderator has requested an action that has not yet been complied with e.g Title change or Code tags...etc. Thanks.

    ALSO

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    09-25-2014
    Location
    denver co
    MS-Off Ver
    2013
    Posts
    5

    Re: Run time error 1004 and i cant figure out why??

    Yes that helped Thank you!!

  5. #5
    Registered User
    Join Date
    09-25-2014
    Location
    denver co
    MS-Off Ver
    2013
    Posts
    5

    Re: Run time error 1004 and i cant figure out why??

    I have changed the code

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Run time error 1004 and i cant figure out why??

    Hi, vmandonado,

    if you want to save in the format of xlsx (used from 2007 on) it would be
    FileFormat:=51
    or
    FileFormat:=xlOpenXMLWorkbook
    while on the other hand the constant xlExcel8 would require the extension of xls.

    HTH,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  2. Vlookup in VBA error 1004 - can't figure out what's wrong.
    By lordterrin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-07-2014, 02:23 PM
  3. [SOLVED] Advanced Filtering -Runtime Error 1004. Cannot figure out why will not work.
    By thelisa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2013, 08:00 AM
  4. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By rich5665@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1