Thanks for any suggestions.
Tony.
> How can I return as a string the name of the folder in which an Excel
> 97 doc is contained?
The property ActiveWorkbook.Path will return the path of the active
work book. To extract the folder only from a full path, use a function
such as this:
Function GetFolder(SourcePath As String) As String
'extracts the folder name from a complete document path
Dim x, oldx As Integer
x = 1
Do While True
x = InStr(x + 1, SourcePath, Application.PathSeparator)
If x = 0 Then
Exit Do
End If
oldx = x
Loop
GetFolder = Left(SourcePath, oldx - 1)
End Function
e.g to return the path of the active document, use:
Sub TestFunction
Msgbox(GetFolder(ActiveWorkbook.FullPath))
End Sub
(obviously, in this case using ActiveWorkbook.Path would return the
same thing, but its only an example!)
HTH,
Dave.
In article <38fad88b...@nntp.netcomuk.co.uk>,
Sent via Deja.com http://www.deja.com/
Before you buy.