path read from file

B

balu

is it possible to refer some string variable to read from single line of an
external notepad or word file
for the sake of refering the path of sum data base to open
kindly advise
 
D

Douglas J. Steele

To read a line from a text file, try something like:

Dim intFile As Integer
Dim strFile As String
Dim strBuffer As String

strFile = "C:\Folder\File.txt"
intFile = FreeFile()
Open strFile For Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, strBuffer
Debug.Print strBuffer
Loop
Close #intFile

(The code above opens the file, reads each line in the file into strBuffer
and prints what it just read to the Immediate window: Ctrl-G)

To read a line from a Word file would involve Automation (and Word being
installed on the machine), so I wouldn't recommend going that route.

My personal preference is to use .INI files. You can read them using the
GetPrivateProfileString API function. Randy Birch has an example (albeit
aimed at VB programmers, not Access programmers) at
http://vbnet.mvps.org/code/internet/inetfavinfo.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top