If some one could help that would be great.
I'm opening a diologue box, in order to save a file in a specific folder. I think thi is sopme common dialog control. Any way I got the following code from a previous thread, along with a bit more which I stuck some where else. Any way, it works great, only problem is, it doesn't ope as modal, so a user can click on the form underneath, which is modal and then there is potrential for it to really go wrong. I'm sure that the answer I'm looking for is just a line or slight modification, but i don't really understand all this ADI functuions and ole stuff.
Thanks for any help.
Public Function GetFolder(dlgTitle As String, Frmhwnd As Long, TheForm As Form) As String
Dim intNullChr As Integer
Dim IngIDlist As Long
Dim IngResult As Long
Dim strFolder As String
Dim BI As shellBrowseInfo
With BI
.hwndOwner = Frmhwnd
.IpszTitle = dlgTitle
.uIFlags = BIF_RETURNONLYFSDIRS
End With
IngIDlist = SHBrowseForFolder(BI)
If IngIDlist <> 0 Then
strFolder = String$(MAX_PATH, 0)
IngResult = SHGetPathFromIDList(IngIDlist, strFolder)
Call CoTaskMemFree(IngIDlist) 'frees the ole pointer to InglDlist
intNullChr = InStr(strFolder, vbNullChar)
If intNullChr Then
strFolder = Left$(strFolder, intNullChr - 1)
End If
Else
GetFolder = "Empty"
Exit Function
End If
GetFolder = strFolder
End Function
I'm opening a diologue box, in order to save a file in a specific folder. I think thi is sopme common dialog control. Any way I got the following code from a previous thread, along with a bit more which I stuck some where else. Any way, it works great, only problem is, it doesn't ope as modal, so a user can click on the form underneath, which is modal and then there is potrential for it to really go wrong. I'm sure that the answer I'm looking for is just a line or slight modification, but i don't really understand all this ADI functuions and ole stuff.
Thanks for any help.
Public Function GetFolder(dlgTitle As String, Frmhwnd As Long, TheForm As Form) As String
Dim intNullChr As Integer
Dim IngIDlist As Long
Dim IngResult As Long
Dim strFolder As String
Dim BI As shellBrowseInfo
With BI
.hwndOwner = Frmhwnd
.IpszTitle = dlgTitle
.uIFlags = BIF_RETURNONLYFSDIRS
End With
IngIDlist = SHBrowseForFolder(BI)
If IngIDlist <> 0 Then
strFolder = String$(MAX_PATH, 0)
IngResult = SHGetPathFromIDList(IngIDlist, strFolder)
Call CoTaskMemFree(IngIDlist) 'frees the ole pointer to InglDlist
intNullChr = InStr(strFolder, vbNullChar)
If intNullChr Then
strFolder = Left$(strFolder, intNullChr - 1)
End If
Else
GetFolder = "Empty"
Exit Function
End If
GetFolder = strFolder
End Function