+ Reply to Thread
Results 1 to 3 of 3

Open workbook from network location - error handling

Hybrid View

  1. #1
    Registered User
    Join Date
    02-05-2011
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    56

    Open workbook from network location - error handling

    One of the steps in a marco I'm working on is opening a workbook from another drive.
    I've specified the location of the workbook with a private function:


    Private Function document() As String
                    document= "\\directory\example.xlsx"
    End Function
    It is on a network drive.
    This means of course that depending on the user's physical location, the macro may or may not be able to find the network path.
    How do I handle the possible error for this? My first idea was something like

    if iserror(Workbooks.Open Filename:=document) = true then
    [action]
    else
    [other action]
    This should also give you some idea of the VBA skill level I'm at
    Any pointers in the right direction are welcome!

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Open workbook from network location - error handling

    Hi,

    I suggest you have a look at this page

    http://www.vbaexpress.com/kb/getarticle.php?kb_id=559

    Here you get a code sample and how to use it, to check if a directory exists.
    Please take time to read the forum rules

  3. #3
    Registered User
    Join Date
    02-05-2011
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Open workbook from network location - error handling

    exactly what I needed. Thanks friend!

+ 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