Consulting

Results 1 to 5 of 5

Thread: Solved: open network drive

  1. #1
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location

    Solved: open network drive

    hi all..

    i'm trying to

    1. Connect to a network drive.
    2. Open spreadsheet.
    3. Update the links ( automatically done ).
    4. Save and exit spreadsheet.
    5. Close network connection.

    Below is the vba code I?m using.

    [vba]Sub opennetworklinkfile()
    Shell ("net use x: /d")
    Shell ("net use x: \\festini\coldstore$ /user:wms\coldxp coldxp")
    ChDir "X:\Data Transfer"
    Workbooks.Open Filename:="X:\Data Transfer\Link to the Gold Plan file.xls", _
    UpdateLinks:=3
    Range("H1").Select
    ActiveWorkbook.Save
    ActiveWindow.Close
    Shell ("net use x: /d")
    End Sub[/vba]

    I get a run-time error ?76? ?Path Not Found?.

    any ideas.

    thanks

  2. #2
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    Here's a little more rebuost way to map the network drive.


    [VBA]
    Dim WshShell As Object, WshNetwork As Object
    'Map Drive
    DriveLetter = "H:" 'must be capitalized
    RemotePath = "\\ServerName\common"
    WshNetwork.MapNetworkDrive DriveLetter, RemotePath
    [/VBA]

    Give that a try and let us know what happens.

    HTH
    Cal
    The most difficult errors to resolve are the one's you know you didn't make.


  3. #3
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location
    thanks for the reply CBrine,

    still lost with your code, so i've been playing around with my code and got it to work.



    [vba]Sub opennetworklinkfile()
    Shell "net use X: \\festini\coldstore$ /user:WMS\coldxp coldxp"
    ChDir "X:"
    Workbooks.Open Filename:="X:\Data Transfer\Link to the Gold Plan file.xls", _
    UpdateLinks:=3
    Range("H1").Select
    ActiveWorkbook.Save
    ActiveWindow.Close
    Shell "net use X: / delete"
    Shell "net use X: / d"
    End Sub[/vba]


    if you have any more ideas please reply back.

    thanks again.

  4. #4
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    CCKfm2000,
    No worries, as long as your have it working. There is some reduntant code you may want to remove.

    [vba]
    sub opennetworklinkfile()
    Shell "net use X: \\festini\coldstore$ /user:WMS\coldxp coldxp"
    ChDir "X:"
    Workbooks.Open Filename:="X:\Data Transfer\Link to the Gold Plan file.xls", _
    UpdateLinks:=3
    ActiveWorkbook.close true
    Shell "net use X: / delete"

    Shell "net use X: / d"
    End Sub

    [/vba]


    The most difficult errors to resolve are the one's you know you didn't make.


  5. #5
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location
    thanks CBrine,

    will update my spreadsheet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •