![]() |
Save filename as new file name
On the first page of my excel workbook I have the A column stretched out to a
column width of 54. To the right side of this sheet I have a button called "Find Record" that populates column A with all records contained in the excel folder on drive F. What my boss wants (and what I'm attempting to do) is to be able to select a file from the list in column A. Then by clicking on the "Rename" button he could enter in a new name for the file, and have the file name changed to the new name he inputs. I have part of the code worked out, but I am having alot of trouble getting the new name to replace the old name. Here is the code: Private Sub cmdRename_Click() Dim sFileName As String, sPath As String, rFileName As String sFileName = ActiveCell.Select sPath = "F:\excel\" rFileName = InputBox("") End Sub Any help or advice would be greatly appreciated. c_ascheman |
Save filename as new file name
Assuming your problem is that you don't know how to rename the files,
how about this? Private Sub cmdRename_Click() Dim sFileName As String, sPath As String, rFileName As String sFileName = ActiveCell.Select sPath = "F:\excel\" rFileName = InputBox("") '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''' 'If new name is entered and that is different from old one. If rFileName < "" And UCASE(rFileName) < UCASE(sFileName) Then Name sPath & sFileName as sPath & rFileName End If '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''' End Sub |
All times are GMT +1. The time now is 02:57 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com