Excel VBA - use UNC path to open Access database

  • The spreadsheet that I am working on uses drive letters to access files. I'm trying to convert them to UNC paths. I have to open external Excel spreadsheets, and an Access database. The spreadsheets are opening fine with UNC paths, however I can't get the Access database to open.


    I get an error message stating that the database is missing, open exclusively by another user, or not an ADP file. I can access it using the drive letter in the path.




    Code
    1. Dim accD As Object
    2. Application.DisplayAlerts = False
    3. Set accD = CreateObject("Access.Application")
    4. accD.Visible = False
    5. accD.OpenCurrentDatabase ("\\main.int\shares\Group1\subMainFolder\nameFolder\Project\sample.accdb")


    Thank you in advance for any help.

  • Re: Excel VBA - use UNC path to open Access database


    Here is a work around that I came up with for right now. It works no matter which computer I run the code from, however I would rather just open my Database using UNC if I can:


  • Re: Excel VBA - use UNC path to open Access database


    I got it to work by changing the directory, at each level, down to the file that I'm opening. So it is working now.