Dear All vba programmer
I have data (.shp, .txt) dan mxd file that store in directory D, I want my application can be run in every directory without changing data address in code. Below is my code without using path
Private Sub UserForm_Initialize()
Dim strFile1 As String
strFile1 = "D:\APLIKASI SIL\Data Teks\LandUnit.txt"
Dim strLandUnit As String
Open strFile1 For Input As #1
Do Until EOF(1)
Input #1, strLandUnit
cboSatuanLahan.AddItem strLandUnit
Loop
Close #1
Dim strFile2 As String
strFile2 = "D:\APLIKASI SIL\Data Teks\Kabupaten.txt"
Dim strKabupaten As String
Open strFile2 For Input As #2
Do Until EOF(2)
Input #2, strKabupaten
cboKabupaten.AddItem strKabupaten
Loop
Close #2
End Sub
I have tried this way to change:
strFile1 = "D:\APLIKASI SIL\Data Teks\LandUnit.txt"
to
strFile1 = App.Path & "\APLIKASI SIL\Data Teks\LandUnit.txt"
and
strFile2 = "D:\APLIKASI SIL\Data Teks\Kabupaten.txt"
to
strFile2 = App.Path & "\APLIKASI SIL\Data Teks\Kabupaten.txt"
But .Path is unknown in vba
I doo need someone help to solve this problem.
Thanks a lot
Yosie