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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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
Back
Top