![]() |
Actual Saved FileName begins with Space
The below code saves my file with a Space
for the first character in the filename. This is not desirable. How can I eliminate this problem? TIA, _MyFile r-111 Apr 2006.xls << where _ is actually a space Sub SaveWithCellName() Dim s As String, s1 As String Dim MyDir As String On Error Resume Next MyDir = "C:\Documents and Settings\Jim May\My Documents\MyExcelFormulas\" ChDir (MyDir) s = ActiveSheet.Range("G1").Text s1 = Range("G2").Text _ & Format(Range("G3"), "mmm yyyy") & ".xls" ActiveWorkbook.SaveAs s & s1 On Error GoTo 0 If Dir(s & s1) < "" Then MsgBox s1 & " successfully saved" Else MsgBox "Problems " End If End Sub |
Actual Saved FileName begins with Space
Try:
s = Trim(Range("G1").Text) HTH -- AP "Jim May" a écrit dans le message de news:cl80g.20654$s%6.6638@dukeread02... The below code saves my file with a Space for the first character in the filename. This is not desirable. How can I eliminate this problem? TIA, _MyFile r-111 Apr 2006.xls << where _ is actually a space Sub SaveWithCellName() Dim s As String, s1 As String Dim MyDir As String On Error Resume Next MyDir = "C:\Documents and Settings\Jim May\My Documents\MyExcelFormulas\" ChDir (MyDir) s = ActiveSheet.Range("G1").Text s1 = Range("G2").Text _ & Format(Range("G3"), "mmm yyyy") & ".xls" ActiveWorkbook.SaveAs s & s1 On Error GoTo 0 If Dir(s & s1) < "" Then MsgBox s1 & " successfully saved" Else MsgBox "Problems " End If End Sub |
Actual Saved FileName begins with Space
ActiveWorkbook.SaveAs Trim(s) & Trim(s1)
-- Regards, Tom Ogilvy "Jim May" wrote in message news:cl80g.20654$s%6.6638@dukeread02... The below code saves my file with a Space for the first character in the filename. This is not desirable. How can I eliminate this problem? TIA, _MyFile r-111 Apr 2006.xls << where _ is actually a space Sub SaveWithCellName() Dim s As String, s1 As String Dim MyDir As String On Error Resume Next MyDir = "C:\Documents and Settings\Jim May\My Documents\MyExcelFormulas\" ChDir (MyDir) s = ActiveSheet.Range("G1").Text s1 = Range("G2").Text _ & Format(Range("G3"), "mmm yyyy") & ".xls" ActiveWorkbook.SaveAs s & s1 On Error GoTo 0 If Dir(s & s1) < "" Then MsgBox s1 & " successfully saved" Else MsgBox "Problems " End If End Sub |
All times are GMT +1. The time now is 03:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com