ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Capturing Unknown Subfolder Name (https://www.excelbanter.com/excel-programming/336323-capturing-unknown-subfolder-name.html)

Roy Harrill

Capturing Unknown Subfolder Name
 
Hi All,

I'm trying to find a way to capture a string containing the pathname of a
folder's subfolder.

For example, assume the root directory has two subfolders, named
"mynewstuff" and "myoldstuff", but you (the programmer) don't know these
names ahead of time. What code would produce a string array containing (at
element 0) "c:\mynewstuff\" and (at element 1) "c:\myoldstuff"? My goal is
to create an array containing the pathnames of all the folders on the
computer (and network if present). This s/b fairly easy using a recursive
looping routine, starting with the root directory and drilling down getting
the name of each folder's immediate subfolder(s).

I thought about trying to use ChDir to somehow get to the subfolder and then
using CurDir to get the full path, but I can't use ChDir without a specific
subfolder path, which of course is what I'm seeking.

Application.FileSearch.SearchScopes possibly could help, but I can't
determine whether it would or not.

I know the Subfolders property of File System Objects in Windows Script is
just what I need, but I must avoid using FSO due to security concerns.

I would appreciate any help with VBA or Office (Excel) code that would
generate an unknown subfolder path string.

TIA.

Roy



Tim Williams

Capturing Unknown Subfolder Name
 
If you can use VBA you already have full access to the filesystem, so what's
the problem with using FSO ?

In this context its use has no impact on security.


Tim

--
Tim Williams
Palo Alto, CA


"Roy Harrill" wrote in message
...
Hi All,

I'm trying to find a way to capture a string containing the pathname of a
folder's subfolder.

For example, assume the root directory has two subfolders, named
"mynewstuff" and "myoldstuff", but you (the programmer) don't know these
names ahead of time. What code would produce a string array containing (at
element 0) "c:\mynewstuff\" and (at element 1) "c:\myoldstuff"? My goal is
to create an array containing the pathnames of all the folders on the
computer (and network if present). This s/b fairly easy using a recursive
looping routine, starting with the root directory and drilling down

getting
the name of each folder's immediate subfolder(s).

I thought about trying to use ChDir to somehow get to the subfolder and

then
using CurDir to get the full path, but I can't use ChDir without a

specific
subfolder path, which of course is what I'm seeking.

Application.FileSearch.SearchScopes possibly could help, but I can't
determine whether it would or not.

I know the Subfolders property of File System Objects in Windows Script is
just what I need, but I must avoid using FSO due to security concerns.

I would appreciate any help with VBA or Office (Excel) code that would
generate an unknown subfolder path string.

TIA.

Roy





Roy Harrill

Capturing Unknown Subfolder Name
 
Tim,
I'm not a security guru, but my understanding is that under some enterprise
IT policies, WSH/FSO may be disabled on user's PCs due to the ease by which
it can be used to spread viruses. So if I were planning on others using my
program, some of them couldn't do so if I required WSH/FSO.
Roy


"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
If you can use VBA you already have full access to the filesystem, so
what's
the problem with using FSO ?

In this context its use has no impact on security.


Tim

--
Tim Williams
Palo Alto, CA


"Roy Harrill" wrote in message
...
Hi All,

I'm trying to find a way to capture a string containing the pathname of a
folder's subfolder.

For example, assume the root directory has two subfolders, named
"mynewstuff" and "myoldstuff", but you (the programmer) don't know these
names ahead of time. What code would produce a string array containing
(at
element 0) "c:\mynewstuff\" and (at element 1) "c:\myoldstuff"? My goal
is
to create an array containing the pathnames of all the folders on the
computer (and network if present). This s/b fairly easy using a recursive
looping routine, starting with the root directory and drilling down

getting
the name of each folder's immediate subfolder(s).

I thought about trying to use ChDir to somehow get to the subfolder and

then
using CurDir to get the full path, but I can't use ChDir without a

specific
subfolder path, which of course is what I'm seeking.

Application.FileSearch.SearchScopes possibly could help, but I can't
determine whether it would or not.

I know the Subfolders property of File System Objects in Windows Script
is
just what I need, but I must avoid using FSO due to security concerns.

I would appreciate any help with VBA or Office (Excel) code that would
generate an unknown subfolder path string.

TIA.

Roy








All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com