How to open a text file using a relative path?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have a config.txt file in a folder that contains a .mdb file. I want to write code in the .mdb file to open the config.txt file. How do I supply a relative path for Open file_path for Input as #1? Thanks
 
Try this:

Dim theFile As String
Dim slashPos As Long

theFile = currentdb.Name 'get the db name and full path
slashPos = InStrRev(theFile, "\")
theFile = Left(theFile, slashPos)
& "config.txt" 'append the name of the config file
'then open theFile however you already are doing it
-----Original Message-----
Hi, I have a config.txt file in a folder that contains
a .mdb file. I want to write code in the .mdb file to
open the config.txt file. How do I supply a relative path
for Open file_path for Input as #1? Thanks
 
Back
Top