Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default To Bob Phillips ( Filesystem)

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default To Bob Phillips ( Filesystem)

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default To Bob Phillips ( Filesystem)

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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default To Bob Phillips ( Filesystem)

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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default 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









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default To Bob Phillips ( Filesystem)

Yes, based on seeing the code, GetFolder is a Function. Without knowing
what you are doing, you just would call GetFolder above you loop, assigning
the results to a string variable (sStr below). Then utilize it inside you
loop if it is appropriate . . .


Dim sStr as String
sStr = GetFolder()
if sStr = "" then exit sub

for i = 1 to 10

' use sStr
Next


or if you are opening a single workbook and you want to process that
workbook inside you loop

Dim sStr as String
Dim bk as Workbook
sStr = GetFolder()
if sStr = "" then exit sub

set bk = Workbooks.Open(sStr)
for i = 1 to 10
if bk.Worksheets(1).Cells(i,1).Value = "ABCD" Then

End if
Next


--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
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









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default To Bob Phillips ( Filesystem)

Sorry sorry soryy
I have it now

Thanks for the help

Alvin


"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







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
to Bob Phillips Jack Sons Excel Discussion (Misc queries) 15 August 28th 07 02:51 PM
Filesystem again Alvin Hansen[_2_] Excel Programming 3 January 31st 05 07:55 PM
Bob phillips?? gav meredith[_2_] Excel Programming 1 April 20th 04 01:41 PM
Bob Phillips Mickey[_3_] Excel Programming 1 March 5th 04 08:46 PM
Bob Phillips boblauder[_2_] Excel Programming 2 January 21st 04 03:28 PM


All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"