Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Getting folder paths

All,

I have the following line of code which gets the full path (iPath) of a file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Getting folder paths

Presumably FindBack works from the end to find a \?

What is sRoot?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dd" <dd.dd wrote in message ...
All,

I have the following line of code which gets the full path (iPath) of a

file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed

under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson




  #3   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Getting folder paths

Bob

sRoot is a string in the module code containing the startPath
startPath is also a string.

Function LoopFolders(startPath As String, _
Optional filetype As String = "RES File", _
Optional subfolders As Boolean = True)

' Create named Ranges, for the appropriate columns in Row 8 of Worksheet
iPathCol = Range("firstPath").Column
iFileCol = Range("firstFile").Column
iLinkCol = Range("firstLink").Column
iFile = Range("firstpath").Row
sRoot = startPath
'--
root is a named cell in the worksheet
path is a named cell in the worksheet

I think FindBack must find the first \ after the root, because there are
several backslashes in the path after the root.
I notice when I miss the \ after the root it adds it to the start of the
path cells. When I add the \ to the root it dissapears from the cells.


"Bob Phillips" wrote in message
...
Presumably FindBack works from the end to find a \?

What is sRoot?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dd" <dd.dd wrote in message ...
All,

I have the following line of code which gets the full path (iPath) of a

file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed

under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Getting folder paths

I thought it was something like that. So isn't sRoot the first folder that
you want?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dd" <dd.dd wrote in message ...
Bob

sRoot is a string in the module code containing the startPath
startPath is also a string.

Function LoopFolders(startPath As String, _
Optional filetype As String = "RES File", _
Optional subfolders As Boolean = True)

' Create named Ranges, for the appropriate columns in Row 8 of

Worksheet
iPathCol = Range("firstPath").Column
iFileCol = Range("firstFile").Column
iLinkCol = Range("firstLink").Column
iFile = Range("firstpath").Row
sRoot = startPath
'--
root is a named cell in the worksheet
path is a named cell in the worksheet

I think FindBack must find the first \ after the root, because there are
several backslashes in the path after the root.
I notice when I miss the \ after the root it adds it to the start of the
path cells. When I add the \ to the root it dissapears from the cells.


"Bob Phillips" wrote in message
...
Presumably FindBack works from the end to find a \?

What is sRoot?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"dd" <dd.dd wrote in message

...
All,

I have the following line of code which gets the full path (iPath) of a

file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed

under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson







  #5   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Getting folder paths

Bob

sRoot is the value that I type into the worksheet in the cell named "root"

The full path is input in the worksheet the the cell named "firstPath"

Instead of havingthe full path in one cell I would like to break it so that
the first directory (after the root) is input in a cell named firstPath and
the remainder of the path is input in the next cell named secondPath.

Regards
Dylan

"Bob Phillips" wrote in message
...
I thought it was something like that. So isn't sRoot the first folder that
you want?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dd" <dd.dd wrote in message ...
Bob

sRoot is a string in the module code containing the startPath
startPath is also a string.

Function LoopFolders(startPath As String, _
Optional filetype As String = "RES File", _
Optional subfolders As Boolean = True)

' Create named Ranges, for the appropriate columns in Row 8 of

Worksheet
iPathCol = Range("firstPath").Column
iFileCol = Range("firstFile").Column
iLinkCol = Range("firstLink").Column
iFile = Range("firstpath").Row
sRoot = startPath
'--
root is a named cell in the worksheet
path is a named cell in the worksheet

I think FindBack must find the first \ after the root, because there are
several backslashes in the path after the root.
I notice when I miss the \ after the root it adds it to the start of the
path cells. When I add the \ to the root it dissapears from the cells.


"Bob Phillips" wrote in message
...
Presumably FindBack works from the end to find a \?

What is sRoot?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"dd" <dd.dd wrote in message

...
All,

I have the following line of code which gets the full path (iPath) of a

file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed

under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson










  #6   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Getting folder paths

Bob,

Function FindBack(text As String, char As String) As Long
Dim i As Long

' This is the InstRev emulator, it works backwards along a string
' to find a specified character.
For i = Len(text) To 1 Step -1
If Mid(text, i, 1) = char Then
FindBack = i
Exit For
End If
Next i
End Function

"Bob Phillips" wrote in message
...
Presumably FindBack works from the end to find a \?

What is sRoot?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dd" <dd.dd wrote in message ...
All,

I have the following line of code which gets the full path (iPath) of a

file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed

under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson





  #7   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Getting folder paths

Bob,

From the worksheet I've copied the present values as follows

The root is a constant and is currently:
P:\Jobs\5048337\Surveys\Trial Surveys\

The Path column contains various paths such as:
Cathcart (Glasgow) Signal Box\Proforma\Fabric\
There will always be three folders in this path.

The filenames are something like:
100205.pfm

To repeat what I'm trying to do, I want to create two columns for the paths.
So that the first part, i.e. the location (Cathcart...) is in the first
column (for Autofiltering)
and the remainder of the path is in the second.

I hope this gives you enough to be able to help me with this.

Dylan.

and the remainder is in the second column.
"Bob Phillips" wrote in message
...
I thought it was something like that. So isn't sRoot the first folder that
you want?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dd" <dd.dd wrote in message ...
Bob

sRoot is a string in the module code containing the startPath
startPath is also a string.

Function LoopFolders(startPath As String, _
Optional filetype As String = "RES File", _
Optional subfolders As Boolean = True)

' Create named Ranges, for the appropriate columns in Row 8 of

Worksheet
iPathCol = Range("firstPath").Column
iFileCol = Range("firstFile").Column
iLinkCol = Range("firstLink").Column
iFile = Range("firstpath").Row
sRoot = startPath
'--
root is a named cell in the worksheet
path is a named cell in the worksheet

I think FindBack must find the first \ after the root, because there are
several backslashes in the path after the root.
I notice when I miss the \ after the root it adds it to the start of the
path cells. When I add the \ to the root it dissapears from the cells.


"Bob Phillips" wrote in message
...
Presumably FindBack works from the end to find a \?

What is sRoot?

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"dd" <dd.dd wrote in message

...
All,

I have the following line of code which gets the full path (iPath) of a

file
(iFile) from a Root directory (sRoot)

Cells(iFile, iPathCol).Value = Mid(oFile.Path, Len(sRoot) + 1,
FindBack(oFile.Path, "\") + 1 - (Len(sRoot) + 1))

I want to split it, so that the first folder in the path is displayed

under
iPathCol1
and the remainder of the path is displayed in iPathCol2.

I don't understand the part after the equals sign!

Can provide a solution for me.

Thanks in advance.

DDawson








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
Paths Ross[_2_] New Users to Excel 1 April 4th 07 11:35 PM
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k[_40_] Excel Programming 6 August 11th 06 08:41 PM
Help with filenames and paths. jim9912 Excel Discussion (Misc queries) 2 March 30th 06 05:52 PM
XP and string paths worf Excel Programming 4 December 8th 05 03:11 AM
UNC Paths Paul Smith[_3_] Excel Programming 1 February 18th 05 12:00 PM


All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"