Finding the path of a .Ini file

maneesh

New Member
Joined
Oct 28, 2002
Messages
5
i have an ini file named sample.ini in the directory where data.xls file is stored .

on a click of a button in the excel file i should be able to locate the the ini file.

in other words first i should get the path where the excel sheet is present and then search that directory for the .ini file
and then read from the ini file

please provide me with vbA code on how to get the path of the excel sheet.

the excel sheet and the .ini file will remain in the same directory
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
On 2002-10-30 03:14, maneesh wrote:
i have an ini file named sample.ini in the directory where data.xls file is stored .

on a click of a button in the excel file i should be able to locate the the ini file.

in other words first i should get the path where the excel sheet is present and then search that directory for the .ini file
and then read from the ini file

please provide me with vbA code on how to get the path of the excel sheet.

the excel sheet and the .ini file will remain in the same directory

Hi;

This may be the answer to your question;

Private Sub CommandButton1_Click()
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(ThisWorkbook.Path)
Set fc = f.Files
For Each f1 In fc
s = f1.Name
If s = "sample.ini" Then
MsgBox "Sample.ini has been found !" & Chr(13) & "The path is ; " & ThisWorkbook.Path & "" & "sample.ini"
Exit Sub
End If
Next
MsgBox "Sample.ini has not been found !"
End Sub
 

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
If the Ini file is in the same Dir as the
Workbook then the Path is just;

ThisWorkbook.Path
 

maneesh

New Member
Joined
Oct 28, 2002
Messages
5
Thank you For ur help

The Code Was really Usefull
Thanks Again
-- Maneesh
 

Forum statistics

Threads
1,144,356
Messages
5,723,887
Members
422,524
Latest member
wirkkarn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top