473,804 Members | 3,424 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\rr a"
ListFolder strStartPath

End Sub
Sub ListFolder(sFol derPath As String)

Dim FS As New FileSystemObjec t
Dim FSfolder As Folder
Dim subfolder As Folder
Dim i As Integer

Set FSfolder = FS.GetFolder(sF olderPath)

For Each subfolder In FSfolder.SubFol ders
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 3034
kadghar
1,295 Recognized Expert Top Contributor
I am using the following code

(...)

Sub ListFolder(sFol derPath 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
7288
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
16957
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
4304
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
1985
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 and I can't allow the program to stock the path names for each brach on the directory tree. The...
0
1355
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
1538
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
12531
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 access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,...
1
2714
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) +141 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 ...
3
3294
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 resides. I'm trying to get the data source to include the FULL path name (which begins with a server...
2
9661
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 TID : 1 PROC : db2fmp (8901) 0 INSTANCE: db2test NODE : 000 EDUID : 1...
1
10329
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9163
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.