+ Reply to Thread
Results 1 to 8 of 8

Save active workbook to other drive error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Save active workbook to other drive error

    Well, i'm back, and unfortunately with the lapse of time have forgot most of which i once knew, but not the fact that you folks saved me countless times. Thank you, once again, for considering my issue-

    I bought a new computer and hooked it up early this week - the previous was almost 14 years old and had too many bandaids to keep it going. I copied my main spreadsheet to the new computer and now am running into a problem trying to save the workbook to an alternate location, as i keep two operationally ready copies. The main difference in my configuration as far as i know is that the program is regularly run from a location on my D: drive, whereas the alternate save is to my C: drive.

    The code line i am using is:
    ActiveWorkbook.SaveAs "C:\Program Files (x86)\Kraken\Kraken.xlsm"
    and the error message as is attached hereto, a runtime error 1004.

    Am i doing something wrong? Is there another method or workaround?

    The code used to work fine when both were on the same drive though in different folders, but that might not be the issue-

    Once again, so many thanks for all of your help over the years-
    -Bruce
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Save active workbook to other drive error


    So weird to save a workbook in an OS folder !

    Anyway as the error message is very explicit, what did you check at least ?!

    As a beginner easy workaround is to save to a well known existing folder …

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,432

    Re: Save active workbook to other drive error

    Try :

    Sub SveWB()
        ActiveWorkbook.SaveAs Filename:="C:\Program Files (x86)\Kraken\Kraken.xlsm", FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled,, CreateBackup:=False
    End Sub

  4. #4
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Re: Save active workbook to other drive error

    @ Logit : Thanks, i'll give it a shot and get back!

    @ Marc L : The reason is that long long ago in a galaxy far far away i started this project with the consideration that it could easily become a commercial offering or a free tool for others in my industry. It handles a vast array of capabilities for employees and brokers of commercial equipment financing and has a number of aux files such as email templates, calculates rates, creates financial documents, has customer traking, history and marketing capabilities, and others. Now that i am getting older, i just don't have it in me to chase down all the bugs, and i find that Excel has inherent "idiosyncrasies" that sporadically crop up, where some routines work great on one run and all of a sudden cause an error - and to correct, all one many times has to do is hit the green arrow in the VBE. Too much trouble. So i just use it for my own business. I run it from a separate location to keep constant historical backups in case any changes in code corrupt it - there are over 50,000 lines, not including those commented out, and i always wanted to have a mirrored copy that would be available as if it was in normal field use. Now i just want to know what the heck went wrong!

  5. #5
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Re: Save active workbook to other drive error

    @Logit - I am getting a Compile error. If i read correctly, it is from the two commas with nothing between them as if the parameter is not optional ans it reads "Expected named parameter" and the second of the two commas is highlighted. After refreshing myself on the SaveAs method, i have eliminated the second comma. Unfortunately i got the attached once again...
    Attached Images Attached Images

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,432

    Re: Save active workbook to other drive error

    I thought you might be able to save to that drive because you are creating another folder within the drive to save to.
    I ran another short macro here and was reminded you don't have permission to save to that specific drive.

    Does the file require the need to be hardcoded ? Can you use the SaveAsFile dialog window ?

    Can the file be saved to the C Drive in the Kraken folder ?

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,432

    Re: Save active workbook to other drive error

    The following will allow you to use a hardcoded path (the saveas filedialog window does not present itself) and the file is saved to the C Drive.

    Sub SaveMe()
    
    Dim newFileFullName As String
    newFileFullName = "C:\Kraken\Kraken" & ".xlsm"               '<--- edit path & file name as required
    
    Application.DisplayAlerts = False
    
    ActiveWorkbook.SaveAs Filename:=newFileFullName, FileFormat _
    :=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    
    Windows("Kraken.xlsm").Application.Quit                           '<-- edit filename as required
    Windows("Kraken.xlsm").Visible = False                            '<-- edit filename as required
    
    End Sub

  8. #8
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Re: Save active workbook to other drive error

    I truly appreciate all your efforts. I can't understand why the heck it is trying to save one of those fragment files (in this case 6D7B9000) instead of "Kraken.xlsm" as i would think it should. We are running into the same issue. I think it is time i stop abusing your good nature and just delete that capability. I just don't get why it worked fine for years and now it won't.

    Thank you for trying so hard to solve this thing!!!
    Attached Images Attached Images

+ 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. Auto-save workbook without prompt on a network drive
    By kc0259 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2019, 03:05 AM
  2. Save as active workbook with module & macro code in (this workbook)
    By nisshaheen76 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2019, 10:24 AM
  3. Macro save workbook to network shared drive folder / curdir not working
    By transporterpilot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2016, 12:43 AM
  4. [SOLVED] Save Active Sheet As New Workbook in same folder of the original workbook
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-19-2012, 07:03 PM
  5. Replies: 2
    Last Post: 06-20-2012, 09:08 PM
  6. Automatically Save Workbook From One Drive To Another
    By SEOT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2010, 09:58 PM
  7. [SOLVED] Excel 2k3: Workbook on network drive, when save creates new file
    By AVCCTech in forum Excel General
    Replies: 1
    Last Post: 07-07-2005, 04:05 PM

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