View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Who do you read an ini file with Excel VBA?

Hi,

This would read an .ini file line by line. The message box isn't necessary,
I put it there to demonstrate it works.

Sub Read_INI()
saveDir = "C:\" 'Place where your INI file is
filenum = FreeFile
targetfile = saveDir & "Myfile.ini" 'Change to your filename
Open targetfile For Input As filenum
Do While Not EOF(filenum)
Input #filenum, Line$
MsgBox Line$
Loop
Close #filenum
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Webtechie" wrote:

Hello,

I need to have a couple of offices use an application. The front end is
written in Excel with Userforms and VBA. The back end is SQL Server.

One office is on site. The other office is in another building. I need to
create a DSN for that office that can see the data across the internet. But
I also need to create an ini file so that the application can retrieve a
value and know whether to access the data directly or use a dsn.

Question
======
What is the code to read an ini from within Excel VBA?


Thanks,

Tony