Actual Saved FileName begins with Space

J

Jim May

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top