+ Reply to Thread
Results 1 to 8 of 8

Macro Will not work to process files stored on network drive.

  1. #1
    Registered User
    Join Date
    08-01-2014
    Location
    Omak, WA
    MS-Off Ver
    2007
    Posts
    7

    Macro Will not work to process files stored on network drive.

    I have been looking at a lot of threads about similar issues but none address my issue.
    I have a macro that works just find on my local machine. but it need to run from a network drive as several different people may need to access it.

    A brief description of the macro.

    The macro looks in an directory called unprocessed for any file named "*.csv"
    if the files are found it opens the file in excel and then copies data from that workbook to my workbook.
    after this the .csv file is closed (unchanged) and then it is moved to the processed directory.

    Sub files()

    Dim directory As String, filename As String, sheet As Worksheet, i As Integer, j As Integer
    Dim filetype As String
    Application.ScreenUpdating = False
    directory = "\\my network path\unprocessed\*.cvs"

    filename = Dir(directory)

    If Len(filename) = 0 Then
    MsgBox "No New files to process."
    End If
    Do While filename <> "" -if file exists
    -...
    -...
    -... code to process files should work if file name holds the correct filename.
    -...
    -...
    filename = Dir() -get next file
    Loop
    ThisWorkbook.Save -save the new workbook.
    End Sub

    this code does not work if I use a mounted drive either
    directory = "Z:\unprocessed\*.cvs"

    I have been banging my head on this one for a week now.
    Thanks in advance.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Macro Will not work to process files stored on network drive.

    Can you wrap your code in code tags please? Highlight the code (and only the code) then press the "#" button.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    08-01-2014
    Location
    Omak, WA
    MS-Off Ver
    2007
    Posts
    7

    Re: Macro Will not work to process files stored on network drive.

    sorry I am new and I am not quite sure what you mean by wrap the code with tags
    but I think with do it.

    Please Login or Register  to view this content.

  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: Macro Will not work to process files stored on network drive.

    Computers are annoyingly literal:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Macro Will not work to process files stored on network drive.

    If you don't mind changing your approach slightly, I have lots of variations of this code (below) that work really well on my network:


    Please Login or Register  to view this content.
    Also, ALWAYS use the Fully-Qualified-Domain-Name for the paths. \\ServerName\ShareName\ instead of Z:\ That way the routine will know where to go no matter which computer your run this from (doesn't have to know about any Z drive).
    Last edited by GeneralDisarray; 08-01-2014 at 02:21 PM.

  6. #6
    Registered User
    Join Date
    08-01-2014
    Location
    Omak, WA
    MS-Off Ver
    2007
    Posts
    7

    Re: Macro Will not work to process files stored on network drive.

    THANK YOU THANK YOU.
    I can not say that enough.
    By the way I only tried to use Z: because nothing else was working.
    I always prefer to use fully qualified path name.
    again I cannot thank you enough.

    oh and did I say thank you.

  7. #7
    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: Macro Will not work to process files stored on network drive.

    If we only knew who you were thanking, one of us would say you're welcome.

  8. #8
    Registered User
    Join Date
    08-01-2014
    Location
    Omak, WA
    MS-Off Ver
    2007
    Posts
    7

    Re: Macro Will not work to process files stored on network drive.

    Sorry Shg, I was so excited that it was working I forgot to mention that GeneralDisarray's solution worked.
    thanks again everyone for your help.

+ 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. Change chdrive to work with network drive
    By brad999 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 12:34 PM
  2. [SOLVED] Macro opens to specific folder BUT doesnt work for network drive
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2013, 06:27 PM
  3. Calling a common XLA Library file, stored on a network drive :)
    By eXcellence in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-28-2005, 12:05 PM
  4. Replies: 5
    Last Post: 06-28-2005, 12:05 PM
  5. Need Macro1 to call Macro2 stored on Network drive
    By LESman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2005, 06: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