+ Reply to Thread
Results 1 to 3 of 3

Path to a network drive

  1. #1
    CWillis
    Guest

    Path to a network drive

    I have written a quick macro to copy data from one workbook to another. It
    works fine for the folder on my C: drive. It doesn't work for my network
    drive...O: Is there something that needs to be written differently in the
    code because it isn't my c: drive?

    code:

    Sub Loaddata()

    With Sheet23.Range("A1")
    .Formula = "='C:\Documents and
    Settings\myname\Desktop\LoopPractice\[looppracticev3.xls]sheet2'!A3"
    '.Formula =
    "='O:\foldername1\foldername2\foldername3\[MockUp_Module1_Feasibility
    v1a.xls]sheet1'!A3" 'this one doesn't work when uncommented
    .Formula = .Value
    End With

    End Sub

    Thanks,
    Chris

  2. #2
    CWillis
    Guest

    RE: Path to a network drive

    Turns out it wasn't the fact it was in a different drive but that there was a
    space in the name. Not sure how to get around that other than "don't put
    spaces in file name"....

    "CWillis" wrote:

    > I have written a quick macro to copy data from one workbook to another. It
    > works fine for the folder on my C: drive. It doesn't work for my network
    > drive...O: Is there something that needs to be written differently in the
    > code because it isn't my c: drive?
    >
    > code:
    >
    > Sub Loaddata()
    >
    > With Sheet23.Range("A1")
    > .Formula = "='C:\Documents and
    > Settings\myname\Desktop\LoopPractice\[looppracticev3.xls]sheet2'!A3"
    > '.Formula =
    > "='O:\foldername1\foldername2\foldername3\[MockUp_Module1_Feasibility
    > v1a.xls]sheet1'!A3" 'this one doesn't work when uncommented
    > .Formula = .Value
    > End With
    >
    > End Sub
    >
    > Thanks,
    > Chris


  3. #3
    Dave Peterson
    Guest

    Re: Path to a network drive

    Maybe you could check to see if the file exists before you use it in the
    formula:

    Dim TestStr as string
    dim myFileName as string

    myfilename = "C:\.......that long string...\something.xls"

    teststr = ""
    on error resume next
    teststr = dir(myfilename)
    on error goto 0

    if teststr = "" then
    'not found
    else
    'file found!
    end if

    I think Ron de Bruin has some code to check to see if the worksheet actually
    exists using some ADO stuff.

    You may want to search his site:
    http://www.rondebruin.nl/

    If you're interested.


    CWillis wrote:
    >
    > Turns out it wasn't the fact it was in a different drive but that there was a
    > space in the name. Not sure how to get around that other than "don't put
    > spaces in file name"....
    >
    > "CWillis" wrote:
    >
    > > I have written a quick macro to copy data from one workbook to another. It
    > > works fine for the folder on my C: drive. It doesn't work for my network
    > > drive...O: Is there something that needs to be written differently in the
    > > code because it isn't my c: drive?
    > >
    > > code:
    > >
    > > Sub Loaddata()
    > >
    > > With Sheet23.Range("A1")
    > > .Formula = "='C:\Documents and
    > > Settings\myname\Desktop\LoopPractice\[looppracticev3.xls]sheet2'!A3"
    > > '.Formula =
    > > "='O:\foldername1\foldername2\foldername3\[MockUp_Module1_Feasibility
    > > v1a.xls]sheet1'!A3" 'this one doesn't work when uncommented
    > > .Formula = .Value
    > > End With
    > >
    > > End Sub
    > >
    > > Thanks,
    > > Chris


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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