To Bob Phillips ( Filesystem)
Hi Tom I believe its because you don't have see all the code her it is:
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'-------------------------------------------------------------
Function GetFolder(Optional ByVal Name As String = _
"Select a folder.") As String
'-------------------------------------------------------------
Dim bInfo As BROWSEINFO
Dim path As String
Dim oDialog As Long
bInfo.pidlRoot = 0& 'Root folder = Desktop
bInfo.lpszTitle = Name
bInfo.ulFlags = &H1 'Type of directory to Return
oDialog = SHBrowseForFolder(bInfo) 'display the dialog
'Parse the result
path = Space$(512)
GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then
GetFolder = Left(path, InStr(path, Chr$(0)) - 1)
End If
End Function
"Tom Ogilvy" skrev:
GetFolder isn't a function. In any event, run that code outside your loop.
GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then
GetFolder = Left(path, InStr(path, Chr$(0)) - 1)
sStr = GetFolder
End If
for i = 1 to 10
msgbox sStr
Next
--
Regards,
Tom Ogilvy
"Alvin Hansen" wrote in message
...
HI bob
Well if i use Gerfolder or
use str like you write
Dim sStr as String
sStr = GetFolder
then it run getfolder every time i run
in my
For and next
Like if i have
For i = 1 to 10
getfolder
next
then it run the function getfolder evry time
I want to run getfolder before i run my for and next
and here have the variable
like
Str = getfolder
for i = 1 to 10
Str
next
Hope you understand
Alvin
"Tom Ogilvy" skrev:
GetFolder is a variable.
if you want its contents in another variable then
Dim sStr as String
sStr = GetFolder
--
Regards,
Tom Ogilvy
"Alvin Hansen" wrote in message
...
Hi Bob
I use the code you paste i a question i have before
"Filesystem again"
It is a Getfolder function
with this lines in last of the function
GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then
GetFolder = Left(path, InStr(path, Chr$(0)) - 1)
End If
Now i want to use this path in a
For
And
Next
So i have to have the value from getfolder into a variable
How do i do that?
Best regards Alvin
|