+ Reply to Thread
Results 1 to 11 of 11

Macro to save file in shared network drive

  1. #1
    Registered User
    Join Date
    04-30-2019
    Location
    San Antonio
    MS-Off Ver
    365
    Posts
    7

    Macro to save file in shared network drive

    I am trying to get this file to be saved in a network drive mapped on my computer. I just want to save it and not close out the file or anything. What I have so far is listed below. I want the file name to be "Bread Reconciliation" + "Whatever date that is listed in cell D1 on Sheet "Bread Input" ". I keep getting this error: Run-time error'1004': Method 'SaveAs' of object'_Workbook' failed
    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Macro to save file in shared network drive

    What's in Sheets("Bread Input").Range("BD1").Value?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-30-2019
    Location
    San Antonio
    MS-Off Ver
    365
    Posts
    7

    Re: Macro to save file in shared network drive

    Its "=D1" and in D1 it is a date that is entered in the mm/dd/yyyy format (4/30/2019.

    So in BD1 it references the short date and I added a custom format where it displays "Bread Reconciliation April 30 2019"
    Here is the custom format I have "Bread Reconciliation" mmmm_dd_yyyyy"

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Macro to save file in shared network drive

    Quote Originally Posted by Dscalf1 View Post
    I keep getting this error: Run-time error'1004': Method 'SaveAs' of object'_Workbook' failed
    When I have run into this issue in the past, it is usually one of the following errors:
    1. You don't have Write permissions to that location (test by saving a non-excel file to that location)
    2. The ActiveWorkbook is not in the same format as the file extension you are trying to save it as (.xls)

    If the above are fine, I would then check the following (These are unlikely but could occur)
    1. Does the folder path in FP still exist? Could it have been renamed or moved? Use a function to verify the save path location exists before the saveas
    2. Could the value in BD1 contain characters that are invalid for filenames in Windows? e.g. if variable FN contained a ":", the workbook won't save.
    3. Even if the previous point is fine, Excel has additional restrictions on workbook filenames. I have updated this post to include a function that will check this for you.

    HTH

    P.S. You can use this function to check if the path exists
    Please Login or Register  to view this content.
    You can use the code below to verify that the proposed fullname is valid for Windows
    Please Login or Register  to view this content.
    Last edited by mc84excel; 04-30-2019 at 08:22 PM.

  5. #5
    Registered User
    Join Date
    04-30-2019
    Location
    San Antonio
    MS-Off Ver
    365
    Posts
    7

    Re: Macro to save file in shared network drive

    So Im trying all these codes and functions and nothing is working Im positive the path is right and the folder is still there and I have editing rights to it because I can add and delete things out of it...

    I tried the functions and im not sure if im using them right but i just keep getting value or and empty space back.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Macro to save file in shared network drive

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  7. #7
    Registered User
    Join Date
    04-30-2019
    Location
    San Antonio
    MS-Off Ver
    365
    Posts
    7

    Re: Macro to save file in shared network drive

    I can attach the document however I am trying to save this macro wouldnt do anything in the actual file only save the file in my network drive when a button is pushed..
    Attached Files Attached Files

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Macro to save file in shared network drive

    Use Debug.Print FN after "FN =" line.

    See what comes up in Immediate window. I suspect you'll see "mm/dd/yyyy" format date. Which contains illegal character for file name.

    Use
    Please Login or Register  to view this content.
    Instead of .Value to use formatted cell text as is.
    Last edited by CK76; 05-01-2019 at 04:52 PM. Reason: For clarity, added illegal char part
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  9. #9
    Registered User
    Join Date
    04-30-2019
    Location
    San Antonio
    MS-Off Ver
    365
    Posts
    7

    Re: Macro to save file in shared network drive

    I got compile error expected expression

    Okay so I used the record macro tool and got this code and it is working however how do I get it to change the name based on the date I have in cell BD1 with the words Bread Reconciliation in front of it. Instead of it saving as Bread Reconciliation v4 all the time I want it to save new files with a different name when they click the button

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-30-2019
    Location
    San Antonio
    MS-Off Ver
    365
    Posts
    7

    Re: Macro to save file in shared network drive

    SOLVED:

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Macro to save file in shared network drive

    Quote Originally Posted by Dscalf1 View Post
    I tried the functions and im not sure if im using them right but i just keep getting value or and empty space back.
    They should both return True. If not, you need to change (or make) the save path and/or purge invalid characters from the filename.

+ 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. Double Save On Shared Network Drive
    By othermark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2019, 04:52 PM
  2. 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
  3. Save Macro Template on a network drive as Excel file using a cell value as the name
    By rjagain62 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2014, 03:21 PM
  4. Need Macro that saves a second copy of an Excel spreadsheet to a shared network drive
    By rockhunter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-27-2011, 01:42 PM
  5. Creating macro to save a backup copy of the same file in a shared drive
    By Kiran9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-29-2011, 07:15 AM
  6. Replies: 0
    Last Post: 04-03-2006, 06:45 PM
  7. [SOLVED] Save Macro w Suggested File Name to Network Drive
    By John Michaels in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2006, 07:36 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