Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I have a function that works well in Excel 2003. This function is to get file name from a file path Like: GetFileName("C:\folder1\name1.txt" it returns: "name1.txt" Function GetFileName(fullpath As String) Dim strFInd As String Do Until Left(strFInd, 1) = "\" icount = icount + 1 strFInd = Right(fullpath, icount) If icount = Len(fullpath) Then Exit Do Loop GetFileName = Right(strFInd, Len(strFInd) - 1) End Function But it does not work in Excel 2002, maybe because it does not support Left and Right function in Excel 2002? How to use this function in Excel 2002 then? Thanks! michael |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This idea may be easier
Sub filn() mypath = "c:\yourfolder\yourfilename.xls" myfilename = Dir(mypath) MsgBox myfilename End Sub Sub FindPath() Dim MyFile As String MyFile = ActiveWorkbook.Name MsgBox MyFile End Sub -- Don Guillett SalesAid Software wrote in message oups.com... Hi all, I have a function that works well in Excel 2003. This function is to get file name from a file path Like: GetFileName("C:\folder1\name1.txt" it returns: "name1.txt" Function GetFileName(fullpath As String) Dim strFInd As String Do Until Left(strFInd, 1) = "\" icount = icount + 1 strFInd = Right(fullpath, icount) If icount = Len(fullpath) Then Exit Do Loop GetFileName = Right(strFInd, Len(strFInd) - 1) End Function But it does not work in Excel 2002, maybe because it does not support Left and Right function in Excel 2002? How to use this function in Excel 2002 then? Thanks! michael |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
oh my god. It is too much easier!!
Thank you very much Don! michael |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
glad to help
-- Don Guillett SalesAid Software wrote in message ps.com... oh my god. It is too much easier!! Thank you very much Don! michael |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
What's the difference between excel 2003 and 2005? | Excel Discussion (Misc queries) | |||
Excel 2002: unexplainable difference in sum of columns | Excel Discussion (Misc queries) | |||
Excel 2002 : How to get the difference in a block of data ? | Excel Discussion (Misc queries) | |||
Difference between Publish and Save As Web Page in Excel 2002 | Excel Discussion (Misc queries) | |||
Difference between ExcelXP and Excel 2003 | Excel Worksheet Functions |