ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   editing filename (https://www.excelbanter.com/excel-programming/333963-editing-filename.html)

[email protected][_2_]

editing filename
 
Hi, I have a folder of .prn files which with vba I use,
Sub GetFileNames()
Dim Fname As String
Dim Ftype As String

Ftype = Dir("H:\Sharescope excel update\*.prn")
i = 0
Fname = Ftype
Do Until Fname = ""
i = i + 1
ReDim Preserve Fnames(1 To i)
Fnames(i) = Fname
Fname = Dir
Loop
End Sub
To get the list. When I open the file it opens as aaa.prn,
understandably. I then save this file as a xl workbook using,
ChDir "H:\Trimmed DaTa"
ActiveWorkbook.SaveAs Filename:="H:\Trimmed DaTa\" & Fnames(c) &
"xls ", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
This is not a problem in as much as I can do what I need with the file.
But it saves it as aaa.prnxls. Is there a way of trimming the .prn off
before saving.
Regards Robert


Damon Longworth

editing filename
 
Try using the left function:

left(Fnames(c),len(Fnames(c))-4)

--
Damon Longworth

Don't miss out on the 2005 Excel User Conference
Sept 16th and 17th
Stockyards Hotel - Ft. Worth, Texas
www.ExcelUserConference.com


wrote in message
oups.com...
Hi, I have a folder of .prn files which with vba I use,
Sub GetFileNames()
Dim Fname As String
Dim Ftype As String

Ftype = Dir("H:\Sharescope excel update\*.prn")
i = 0
Fname = Ftype
Do Until Fname = ""
i = i + 1
ReDim Preserve Fnames(1 To i)
Fnames(i) = Fname
Fname = Dir
Loop
End Sub
To get the list. When I open the file it opens as aaa.prn,
understandably. I then save this file as a xl workbook using,
ChDir "H:\Trimmed DaTa"
ActiveWorkbook.SaveAs Filename:="H:\Trimmed DaTa\" & Fnames(c) &
"xls ", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
This is not a problem in as much as I can do what I need with the file.
But it saves it as aaa.prnxls. Is there a way of trimming the .prn off
before saving.
Regards Robert




[email protected][_2_]

editing filename
 
Damon, Thankyou this is perfect.
Regards Robert



All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com