Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide file path on a text box
How can I improve this code?... I want to select a file on the computer, show
the name in a textbox after selected, and then clicking a button to open it. So far this is what I have, is not exactly what I want but it works... what I want to fix right now, is to hide the entire path of the file to be opened and only display the file name... how can I do that? fileToOpen = Application.GetOpenFilename("Excel files (*.xls), *.xls") If fileToOpen < False Then TextBox1.Text = fileToOpen |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide file path on a text box
From J. Walkenbach:
Private Function FileNameOnly(pname) As String ' Returns the filename from a path/filename string Dim i As Integer, length As Integer, temp As String length = Len(pname) temp = "" For i = length To 1 Step -1 If Mid(pname, i, 1) = Application.PathSeparator Then FileNameOnly = temp Exit Function End If temp = Mid(pname, i, 1) & temp Next i FileNameOnly = pname End Function Rgds Mika |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File Path Too Long? Not Anymore! Check out Long Path Tool | Excel Discussion (Misc queries) | |||
Formula too long - new file path is shorter than old file path - Excel 2003 | Excel Worksheet Functions | |||
hide mouse over link path pop up box | Excel Worksheet Functions | |||
How to hide a text file using macro | Excel Discussion (Misc queries) | |||
Import text file without specifying a path macro won't work | Excel Programming |