Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Full folder path from BrowseForFolder

I am trying to create a script that utilizes the BrowseForFolder dialog
box. I want to have it return the full path of the selected folder
rather than just the folder name. Here is what I have so far:

Sub shellb()

Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "Choose folder
to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

All this does is write the folder name to cell A3. Is there a way I
can get this script to record the full path to the folder I selected? I
have read some about the 'GetPathFromIDList' feature but I am not
familiar with it, any suggestions?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Full folder path from BrowseForFolder

This worked ok for me:

Range("A3").Value = objFolder.self.Path


Jon wrote:

I am trying to create a script that utilizes the BrowseForFolder dialog
box. I want to have it return the full path of the selected folder
rather than just the folder name. Here is what I have so far:

Sub shellb()

Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "Choose folder
to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

All this does is write the folder name to cell A3. Is there a way I
can get this script to record the full path to the folder I selected? I
have read some about the 'GetPathFromIDList' feature but I am not
familiar with it, any suggestions?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Full folder path from BrowseForFolder

Hi Jon

You can do it like this

Dim oApp As Object
Dim ofolder
Dim RootPath As String

Set oApp = CreateObject("Shell.Application")
'Browse to the folder
Set ofolder = oApp.BrowseForFolder(0, "Select folder", 512)
If ofolder Is Nothing Then Exit Sub
RootPath = ofolder.Self.Path
MsgBox RootPath


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jon" wrote in message oups.com...
I am trying to create a script that utilizes the BrowseForFolder dialog
box. I want to have it return the full path of the selected folder
rather than just the folder name. Here is what I have so far:

Sub shellb()

Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "Choose folder
to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

All this does is write the folder name to cell A3. Is there a way I
can get this script to record the full path to the folder I selected? I
have read some about the 'GetPathFromIDList' feature but I am not
familiar with it, any suggestions?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Full folder path from BrowseForFolder

Beautiful, thanks Dave!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Full folder path from BrowseForFolder

Now I would like to use that folder path and create a list of files and
their attributes (such as date created, size, type) and paste them into
my document. How would I go about doing this?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Full folder path from BrowseForFolder

Dave,
I give up, where does ".Self" come from?
It is not in the Windows Script Technologies 5.6 help file.
I have used objFolder.Path and objFile.Path without a hitch to return paths.
Very curious.
Regards,
Jim Cone
San Francisco, USA


"Dave Peterson"
wrote in message
...
This worked ok for me:

Range("A3").Value = objFolder.self.Path


Jon wrote:
I am trying to create a script that utilizes the BrowseForFolder dialog
box. I want to have it return the full path of the selected folder
rather than just the folder name. Here is what I have so far:

Sub shellb()
Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "Choose folder
to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

All this does is write the folder name to cell A3. Is there a way I
can get this script to record the full path to the folder I selected? I
have read some about the 'GetPathFromIDList' feature but I am not
familiar with it, any suggestions?


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Full folder path from BrowseForFolder

A copy|pasted Jon's code into a module.

I put a watch on ObjFolder and stepped through the code. Then I expanded that
object in the watch window and saw Self--then I expanded that and saw what I
needed.



Jim Cone wrote:

Dave,
I give up, where does ".Self" come from?
It is not in the Windows Script Technologies 5.6 help file.
I have used objFolder.Path and objFile.Path without a hitch to return paths.
Very curious.
Regards,
Jim Cone
San Francisco, USA

"Dave Peterson"
wrote in message
...
This worked ok for me:

Range("A3").Value = objFolder.self.Path

Jon wrote:
I am trying to create a script that utilizes the BrowseForFolder dialog
box. I want to have it return the full path of the selected folder
rather than just the folder name. Here is what I have so far:

Sub shellb()
Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "Choose folder
to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

All this does is write the folder name to cell A3. Is there a way I
can get this script to record the full path to the folder I selected? I
have read some about the 'GetPathFromIDList' feature but I am not
familiar with it, any suggestions?


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Full folder path from BrowseForFolder

One way:

Option Explicit
Sub shellb()

Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder _
(0, "Choose folder to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
Call ShowFiles(objFolder.self.Path)
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

Sub ShowFiles(myFolderName As String)

Dim FSO As Object
Dim myFolder As Object
Dim myFile As Object
Dim iCtr As Long

Set FSO = CreateObject("Scripting.FileSystemobject")
Set myFolder = FSO.getfolder(myFolderName)

iCtr = 3
For Each myFile In myFolder.Files
iCtr = iCtr + 1
Cells(iCtr, "A").Value = myFile.Path
Cells(iCtr, "B").Value = myFile.Name
Cells(iCtr, "C").Value = myFile.datecreated
Cells(iCtr, "D").Value = myFile.Size
Next myFile

End Sub

Jon wrote:

Now I would like to use that folder path and create a list of files and
their attributes (such as date created, size, type) and paste them into
my document. How would I go about doing this?


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Full folder path from BrowseForFolder

Dave,
Thanks for that. I will have to noodle on it awhile.
Jim Cone


"Dave Peterson"
wrote in message
...
A copy|pasted Jon's code into a module.

I put a watch on ObjFolder and stepped through the code. Then I expanded that
object in the watch window and saw Self--then I expanded that and saw what I
needed.



Jim Cone wrote:

Dave,
I give up, where does ".Self" come from?
It is not in the Windows Script Technologies 5.6 help file.
I have used objFolder.Path and objFile.Path without a hitch to return paths.
Very curious.
Regards,
Jim Cone
San Francisco, USA

"Dave Peterson"
wrote in message
...
This worked ok for me:

Range("A3").Value = objFolder.self.Path

Jon wrote:
I am trying to create a script that utilizes the BrowseForFolder dialog
box. I want to have it return the full path of the selected folder
rather than just the folder name. Here is what I have so far:

Sub shellb()
Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "Choose folder
to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
End If
Set objFolder = Nothing
Set objShell = Nothing

End Sub

All this does is write the folder name to cell A3. Is there a way I
can get this script to record the full path to the folder I selected? I
have read some about the 'GetPathFromIDList' feature but I am not
familiar with it, any suggestions?


--

Dave Peterson


--

Dave Peterson
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
Full path-name in title bar ? Stefan Excel Discussion (Misc queries) 14 January 13th 10 11:00 AM
Full path possible to be seen? Octavio New Users to Excel 10 July 2nd 06 08:51 PM
Full path in title bar ntoze Excel Discussion (Misc queries) 0 February 21st 06 07:26 PM
full UNC path in footer muttdaemon Excel Discussion (Misc queries) 1 October 12th 05 06:21 PM
Full path in taskbar GregR Excel Programming 8 August 9th 05 03:34 AM


All times are GMT +1. The time now is 12:29 AM.

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"