Using UNC address to reference another file

  • Hi all, I have created a workbook named "A" that the windows task scheduler opens.


    "A" contains an open_event macro that autoruns it's code.


    This auto code opens another workbook named "B"


    I referenced "B" with something like this... X:\Documents and Settings\GGR\UPDATE FOLDER


    Here is the code





    But I found when the task scheduler runs when I am not logged in it cannot access drive "X"


    A co-worker suggested I use the unc path name. I tried that but It does not seem to recognize this address (even if I am logged in)


    I just replace the address I had with the hard unc address directly??


    Any suggestions?

  • Re: Using UNC address to reference another file


    Hi Kelly


    You can't Change Dir or Drives using the UNC convention.
    You will need to resort to APIs for this..... adapt this routine...


  • Re: Using UNC address to reference another file


    Thanks Ivan, but I feel I am once again in over my head....


    I gave it an honest effort but not understanding the basics makes it difficult to adapt your code.



    I keep getting the "Could not Change Directory to servername\ConameLtd\KRADOCS\Foldername" error.


    here is the code I amtrying to run....




    Thanks for your help on this

  • Re: Using UNC address to reference another file


    One more thing... I'm not sure I understand this bit of code.


    Code
    If Not lReturn Then 
             '// If the function succeeds, the return value is nonzero.
             '// If the function fails, the return value is zero.
             '// Show the message
            MsgBox "Could not Change Directory to " & strDir 
            Exit Sub 
        End If 
    
    
    'My code here


    Because the value of lReturn is = 0 when I start stepping through the code and changes to = 1 after the two functions run. But either way it could not get past the if statement??


    So if it worked would lReturn = True??


    :?

  • Re: Using UNC address to reference another file


    Ahhh, I tried that and still no-go.


    So success should mean any other value other then = 0?


    Kelly

  • Re: Using UNC address to reference another file


    I changed the If not statement to IF and took out a line of my code that was not working and budda bing budda bang.


    :thanx:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!