Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Beautiful, thanks Dave!
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Full path-name in title bar ? | Excel Discussion (Misc queries) | |||
Full path possible to be seen? | New Users to Excel | |||
Full path in title bar | Excel Discussion (Misc queries) | |||
full UNC path in footer | Excel Discussion (Misc queries) | |||
Full path in taskbar | Excel Programming |