473,513 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Returning subfolder name with path name

9 New Member
I am using the following code

Sub Ck()

Dim strStartPath As String

strStartPath = "d:\workpack\rra"
ListFolder strStartPath

End Sub
Sub ListFolder(sFolderPath As String)

Dim FS As New FileSystemObject
Dim FSfolder As Folder
Dim subfolder As Folder
Dim i As Integer

Set FSfolder = FS.GetFolder(sFolderPath)

For Each subfolder In FSfolder.SubFolders
DoEvents
i = i + 1
'added this line
Cells(i, 1) = subfolder
'commented out this one
'Debug.Print subfolder
Next subfolder

Set FSfolder = Nothing


End Sub

to return the subfolder names into cells in excel, problem is this also returns the path (ie D:\workpack\rra\example1), I only want the subfolder name, how can I do this?
Jan 18 '08 #1
5 3018
kadghar
1,295 Recognized Expert Top Contributor
I am using the following code

(...)

Sub ListFolder(sFolderPath As String)

(...)

to return the subfolder names into cells in excel, problem is this also returns the path (ie D:\workpack\rra\example1), I only want the subfolder name, how can I do this?
the easiest way, since you have sFolderPath:
cells(i,1) = mid(subfolder, len(sFolderPath)+1)

HTH
Jan 18 '08 #2
woolls01
9 New Member
I have no idea what that means but it did the trick so thanks
Jan 18 '08 #3
kadghar
1,295 Recognized Expert Top Contributor
I have no idea what that means but it did the trick so thanks
mid will return a substring from the original string, so if you have

str1 = "hello world"

mid(str1, 2,4) = "ello" where the first parameter is the string, the second is the starting position and the third is the length. The third one is optional, and will give you the rest of the string as default.

HTH
Jan 18 '08 #4
ubentook
58 New Member
Try...
Cells(i, 1) = subfolder.Name


I am using the following code
-snip-
to return the subfolder names into cells in excel, problem is this also returns the path (ie D:\workpack\rra\example1), I only want the subfolder name, how can I do this?
Jan 19 '08 #5
ubentook
58 New Member
Try...
Cells(i, 1) = subfolder.Name

I am using the following code
-snip-
to return the subfolder names into cells in excel, problem is this also returns the path (ie D:\workpack\rra\example1), I only want the subfolder name, how can I do this?
Jan 19 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7273
by: BNM | last post by:
I know there must be a function somewhere for converting a local file path name to the url path (i.e. /user/apache/htdocs/myDir/myFile.jpg to /myDir/myFile.jpg) but I can't find it! Can someone tell me what it is? Thanks! Brett
1
16926
by: Sanjay Godbole | last post by:
Hi, I am getting following error while executing the axpx page. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentNullException: Value
6
4292
by: Jonathan Smith | last post by:
I had a quick look on the newsgroup, but i couldn't find the answer. I have a long path name but i need to be able to extract the shortpath name from it How do i do this?
6
1972
by: Sigmathaar | last post by:
Hi, while making an XML parser for the creation of an entire directory list I got this problem and I'm having trouble solving it. The program (not yet written) goes through an XML Schema Instance to create some directories (about 5000). While creating the directories the XML file that I'm parsing is alphabetically ordered not hierarchically...
0
1351
by: snabakvinod | last post by:
Hi, In VC8 project release mode, using __FILE__ macro and compiler option /FC, I can get the full path name with all small letters(Ex: c:\testvc8project\samplefilename.cpp). But I could not get the full path name with Camel Format(Ex: c:\TestVC8Project\SampleFileName.cpp).
0
1525
by: Vinod | last post by:
Hi, In VC8 project release mode, using __FILE__ macro and compiler option /FC, I can get the full path name with all small letters(Ex: c:\testvc8project\samplefilename.cpp). But I could not get the full path name with Camel Format(Ex: c:\TestVC8Project\SampleFileName.cpp).
2
12460
by: ranjith konnoju | last post by:
hi, i am getting an exception while populating the data in the datagrid. am getting the values into datatable and binding it to the datagrid but it is not displaying the data and giving an exception like System.ArgumentException: Empty path name is not legal. at System.IO.FileStream.Init(String path, FileMode mode, FileAccess...
1
2691
by: ainoy31 | last post by:
Any advice on why I would get this message. System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +3268526 System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) +56 System.Web.HttpServerUtility.Transfer(String path) +32 ProSearch.Page_Load(Object sender, EventArgs e)...
3
3274
by: macraig491 | last post by:
Hello, I have created several pivot tables using external data for which I had to set up a new data source. The data source is a Microsoft Access database. I'm encountering a problem when trying to refresh the pivot tables from another user's computer, as they have a different drive letter mapped to the server where the Access database...
2
9623
by: ranjitkumara | last post by:
Hi All when i am calling libencode.so from function using external library(libtest.so) i am getting below error in db2diag.log means ,its n't able to get the proper GCC library from DB2 Datatbase. --------------------------------------------- 2011-02-25-12.33.48.663266+300 E1493A1058 LEVEL: Error (OS) PID : 33095922 ...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7125
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.