View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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