If I have a workbook that can be copied to and used in any
arbitrary folder, that means each workbook will have
a different path.
Is there a way to determine the path of a workbook??
(Or path of "ThisWorkbook")
Thank you!
Hey Robert!
I use this function below. It presents a "click-and-choose" menu
where the user picks
the folder he wants. Then the code returns it as a string for you to
work. Quite simple, isn't?
First, declare this TYPE in your module:
Public Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Then, use the code below:
Public Function folder_win() As String
Dim lpIDList As Long
Dim folder As String
Dim browse As BrowseInfo ' This TYPE was declared right above
lpIDList = SHBrowseForFolder(browse)
If (lpIDList) Then
folder = Space(260)
SHGetPathFromIDList lpIDList, folder
folder = Left(folder, InStr(folder, vbNullChar))
folder_win = folder
End If
End Function
Hope it helped you out!
Brazillian Hugs!
Ronaldo PARIS