+ Reply to Thread
Results 1 to 10 of 10

Copy all Files From K:\ drive to a folder

  1. #1
    Registered User
    Join Date
    04-02-2013
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Copy all Files From K:\ drive to a folder

    I have a macro that works but I'm trying to schedule it with Windows Scheduler to run at a certain time in the "Run whether user is logged on or not" mode. I have multiple macro's that I'm doing the same thing and have no problems with them. This macro is set up as WorkBook_Open and runs great when I double click on it and also in the "Run only when user is logged on" mode. I am at a loss. I have looked at everything on this site about copying along with all over the internet and i've tried every code I could find. Some worked some did not, but none worked in the "Run whether user is logged on or not" mode. Any help would be appreciated.
    The files are all .txt files.
    I'm on a work computer and have Admin Rights
    Windows 7 Enterprise
    Microsoft Office Professional Plus 2007

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 06-29-2013 at 09:03 AM. Reason: As per Forum Rule #3, please use code tags…Thanks.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Copy all Files From K:\ drive to a folder

    When you created the task in Task Scheduler, did you tick Run whether user is logged in or not?

    Is the file in a trusted directory, or is the project digitally signed, so that the macro will run?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    04-02-2013
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Copy all Files From K:\ drive to a folder

    shg thank you for the quick reply. Yes I have tick the Run whether user is logged in or not. I've set it up exactly like the other excel macro's that I have that work. They are all located in the same folder. How can I tell if the directory is a trusted directory? And I don't think the project is digitally signed..... I have not yet learned how to do that. but I have Macro settings set to "Enable all macros (not recommended;potentially dangerous code can run) and the Developer Macro Settings ticked off the box for Trust access to the VBA project object model.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Copy all Files From K:\ drive to a folder

    I have Macro settings set to "Enable all macros
    I would seriously not do that.

    How can I tell if the directory is a trusted directory?
    Excel options > Trust Center > Trust Center Settings > Trusted Locations

  5. #5
    Registered User
    Join Date
    04-02-2013
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Copy all Files From K:\ drive to a folder

    Ok. I set Macro Settings to "Disable all macros with notification". and I added the folder that all of my Macro's are in to the Trusted Locations. I tested some of the macro's that had been working and they worked fine. But I'm still having the same problem with this one. It says it's running in the scheduler but nothing is happening.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Copy all Files From K:\ drive to a folder

    Ah -- mapped drives don't work when you're not logged in. They are part of user settings. If it's a network share, use a UNC path.

  7. #7
    Registered User
    Join Date
    04-02-2013
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Copy all Files From K:\ drive to a folder

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\hshd>net use
    New connections will be remembered.


    Status Local Remote Network

    -----------------------------------------------------------------------------
    OK K: \\RETUS211-NT0001\EXCHANGE
    Microsoft Windows Network
    OK P: \\RETUS211-NT0001.ikea.com\Common
    Microsoft Windows Network
    OK U: \\RETUS211-NT0001\HSHD$ Microsoft Windows Network
    The command completed successfully.


    C:\Users\hshd>

    So K is the drive I'm trying to use. How would I translate K:\ into UNC path?

    This is what I have now

    "K:\*.*", "\\RETUS211-NT0001.ikea.com\Common\Logistics\Chris\K_Drive\2013\today"

    I've tried a few different ways with no luck.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Copy all Files From K:\ drive to a folder

    This should be the UNC path:

    \\RETUS211-NT0001.ikea.com\Common\Logistics\Chris\K_Drive\2013\today

  9. #9
    Registered User
    Join Date
    04-02-2013
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Copy all Files From K:\ drive to a folder

    shg thank you so much for your help. The UNC path for the K:/ ended up being \\RETUS211-NT0001.ikea.com\EXCHANGE\

    you have helped me so much. Just learning about the UNC path has opened up my eyes to so much more.

    Thank you again

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Copy all Files From K:\ drive to a folder

    You're welcome, glad it helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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