Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting Relative Reference to Access (Excel 2K, Win2K Pro)

    I have a large set of VBA code in an Excel file that pulls data from an Access file and builds charts. In the course of wapping out the code, I used a set path C:/TAP/Tap.mdb to find the db and do stuff. I'd like to re-write the code to find the access file in the root of whatever folder the Excel file is in. Any ideas?

    <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Setting Relative Reference to Access (Excel 2K, Win2K Pro)

    The root - you mean like C: ?

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Relative Reference to Access (Excel 2K

    no, i mean you have folder/folder/FOLDER/Excel.xls TAP.mdb

    so the 'floor' where Excel.xls in on whatever level of a directory should be where the VBA code looks for TAP.mdb. Since I do a lot of web stuff, I am thinking of the logic of an INCLUDE page:

    INCLUDE = "blah" find what's in the same folder; INCLUDE = "../Blah" find the file one folder 'up'. Surely there's something similar in VBA?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Setting Relative Reference to Access (Excel 2K

    Try this:

    Dim strPath As String
    strPath = ActiveWorkbook.Path
    If Not Right(strPath, 1) = "" Then
    strPath = strPath & ""
    End If
    strPath = strPath & "TAP.mdb"

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Relative Reference to Access (Excel 2K

    ah, that works... ActiveWorkbook.path...

    thanks!

Posting Permissions

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