+ Reply to Thread
Results 1 to 10 of 10

Macro works on desktop but not Network environment

  1. #1
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office 365
    Posts
    259

    Macro works on desktop but not Network environment

    Hello, I recently had help from Logit getting a macro created that could save an Excel file - a daily shift attendance sheet - to a specified location on my desktop under a specified name as well as compose an email with the same file attached with pre-populated Subject, Body, and email recipients. That can be found here: https://www.excelforum.com/excel-pro...-and-exit.html. I presented this to the managers here at work and they all loved the idea because it would eliminate needless emails and phone calls when someone didn't receive the sheet that was supposed to and so they gave me to go ahead to get it implemented in the actual network drive where the attendance sheet templates are kept. Basically, they would be saved into a separate folder within that same network drive.Here is the macro for the desktop location to get an idea behind the coding:

    Please Login or Register  to view this content.
    This one is working fine. I had pasted this same macro in the file that is located in the network drive. I changed it to have the file pathway leading to the folder that I would need it saved in there. The coding for that looks like this:

    Please Login or Register  to view this content.
    I didn't realize that a network location would operate differently and that this code would not be valid. It was composing the email just fine, but not saving the file where I wanted it to go. I'm not even sure where it saved it if it even did - I just know it wasn't where intended. Is it completely different coding needed here in the case of network drives? Is something like this actually even possible?
    Last edited by PitchNinja; 06-16-2021 at 02:38 PM.

  2. #2
    Registered User
    Join Date
    06-15-2021
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    34

    Re: Macro works on desktop but not Network environment

    Does everyone have the network location mapped the same? Because if they don't it won't work based off of yours. With our network it makes everyone use it as a Z drive shared nertwork so that everyone has the same one. Re read it seems its not even working for you based off your own parameters. Let me deepdive.

    Edit: You are using the UNC file paths which is smarter than what I do to be fair.

    Edit2: I am testing this on my network and getting the same error as you are as well as its totally locking me out further investigating.

    Edit3: I got it working perfectly fine on the actual shared network we are using. The private side of the network that I can see (even my own private folder) I could not get it to work on. I have the private side of the network configured differently.

    This may be an issue with your file path or your permissions on the shared drive I am the admin so I can read and write to any files on the "Shared" section I can only read what is in the individual private users folders (unless I go onto a different account that requires two upper management to access) Like I said I could not get it to work on my personal private folder on the shared drive because I do not have full perms on this account.

    Can you right click drag the file path you want to a word document and create a hyperlink for it. Then copy and paste that into the actual code. This might also be an issue.

    Your file path looks off to me to be honest.
    Last edited by Zaerick; 06-16-2021 at 09:23 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Macro works on desktop but not Network environment

    If you can put a breakpoint on this line: ActiveSheet.SaveAs Filename:=Name, FileFormat:=52

    Run the code and when it hits that breakpoint, mouse over or look at what your "Name" variable contains, copy that out and paste it into your windows explorer and see if you can access it or if its even valid. I agree that it looks a little off, but not clear on why..

    Name = Environ("UserProfile") & "\\servername\Data\DNS\Group\Warehouse\Management\Absentee tracking\UNFI F21\Perishable 1st\" & _
    Format(Now(), "mmddyy") & " " & "Perishable 1st Shift ABSENTEE BLANK (1ST SHIFT)" & ".xlsm"


    I would copy that value into notepad, then i would manually navigate to the location you are expecting to save the file and manually copy that path into a line below in notepad and just compare and see what is different between your logic string and the actual string
    Last edited by cubangt; 06-16-2021 at 03:28 PM.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  4. #4
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office 365
    Posts
    259

    Re: Macro works on desktop but not Network environment

    Okay so I ended up talking with our IT person and we tried troubleshooting it. The very strange thing is that it works but not consistently. We can't figure out the pattern. He ended up changing the coding to this:

    Please Login or Register  to view this content.
    As you can see, he removed some of the coding in the upper portion where it is telling the file where to save it to and name it. I did leave him a message to call me so that we could take a look at both of these posts and try something out but I did at least want to post what we did. We just can't figure out why it doesn't consistently work.
    Last edited by PitchNinja; 06-17-2021 at 10:05 AM.

  5. #5
    Registered User
    Join Date
    06-15-2021
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    34

    Re: Macro works on desktop but not Network environment

    Quote Originally Posted by PitchNinja View Post
    Okay so I ended up talking with our IT person and we tried troubleshooting it. The very strange thing is that it works but not consistently. We can't figure out the pattern. He ended up changing the coding to this:


    As you can see, he removed some of the coding in the upper portion where it is telling the file where to save it to and name it. I did leave him a message to call me so that we could take a look at both of these posts and try something out but I did at least want to post what we did. We just can't figure out why it doesn't consistently work.
    The part that you removed is not needed.

    I have now ran it 6 times on my network and it worked all 6 times.

  6. #6
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office 365
    Posts
    259

    Re: Macro works on desktop but not Network environment

    So the original file we have called Perishable 1st Shift Test. It should be saving the file in the specific folder with a date in the name as well as Perishable 1st shift. What we were finding is that when we would close out of that test file and then go back in to try and run it, that was when we were having issues of it not working consistently. It would pull up the email fine but it wouldn't always save it and we couldn't figure out what was making it work the times it did. Zaerick, if you delete the file that is automatically created, exit out of everything then reopen the test template, then try to run it, is it consistently working for you when you do all of that 6 times or were you in the file and just ran it 6 times without having closed the file?

  7. #7
    Registered User
    Join Date
    06-15-2021
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    34

    Re: Macro works on desktop but not Network environment

    Quote Originally Posted by PitchNinja View Post
    So the original file we have called Perishable 1st Shift Test. It should be saving the file in the specific folder with a date in the name as well as Perishable 1st shift. What we were finding is that when we would close out of that test file and then go back in to try and run it, that was when we were having issues of it not working consistently. It would pull up the email fine but it wouldn't always save it and we couldn't figure out what was making it work the times it did. Zaerick, if you delete the file that is automatically created, exit out of everything then reopen the test template, then try to run it, is it consistently working for you when you do all of that 6 times or were you in the file and just ran it 6 times without having closed the file?
    If you are saving it more then once a day it will not work because the file name will be the same and you can't save while it is open. As long as I closed the file it created it saved each time.

  8. #8
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office 365
    Posts
    259

    Re: Macro works on desktop but not Network environment

    That could be a problem. Sometimes they who would be using this file need to send out revisions to the sheets which would require emailing and saving them again. Is there some kind of coding or change to the existing coding that could allow for that scenario?

  9. #9
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Macro works on desktop but not Network environment

    Trying saving / overwriting the file, if there is a chance of revisions.

    https://www.teachexcel.com/excel-tut...g-vba-in-excel

  10. #10
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office 365
    Posts
    259

    Re: Macro works on desktop but not Network environment

    Quote Originally Posted by cubangt View Post
    Trying saving / overwriting the file, if there is a chance of revisions.

    https://www.teachexcel.com/excel-tut...g-vba-in-excel
    So I was looking at this article and I saw how it says about having DisplayAlerts.False and DisplayAlerts.True.

    Please Login or Register  to view this content.
    But looking in this code, I see they are already there?

    Here's something strange. I had created a button on the actual workbook for whoever to press it to save/email the sheet and of course assigned this macro to it. I have actually two macros listed that I can assign to it: Email WBAttached, and savesheet. I assigned Email WB attached doing step-by-step:

    1. Open the Perishable 1st Shift Test File
    2. Click the macro-assigned button - only email pops up
    3. Click Developer tab then Visual Basic
    4. Click Run - It saves the file and brings up the email.

    EDIT: I see the problem now. This coding really in essence is two separate macros even though its pasted as one. I need to be able to assign two macros to one button. Is this possible?
    EDIT 2: I created this macro:

    Please Login or Register  to view this content.
    This is running BOTH of these and I created a button and assigned macro2 to it. It is working perfectly!
    Last edited by PitchNinja; 06-17-2021 at 10:50 AM.

+ 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] macro to delete all CSV files on my desktop desktop folders and and its subfolders
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-19-2017, 03:42 PM
  2. Replies: 4
    Last Post: 04-10-2014, 12:11 PM
  3. Add-in Installation in a Network Environment
    By Fowmy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-13-2012, 10:02 AM
  4. OnAction macro assigment through a macro in network environment behaves strange
    By kbx17 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-26-2012, 02:22 PM
  5. Use an icon from a network drive for a desktop shortcut
    By jhize in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-01-2007, 09:22 AM
  6. Workbooks are getting damaged in network environment
    By Mikeyhend in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2006, 07:52 AM
  7. [SOLVED] Desktop file sharing:network drive
    By Anne Troy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM

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