• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

application.getsaveas method

PremSivakanthan

New Member
Hi, I'm having a problem with the following code - the getsave as method works fine, but it comes up with a runtime error, on the saveas line. I think its something to do with the Initialfilename string, but havent been able to figure it out.


Dim sFileName As String

Dim sCampaignName As String

Dim sht As Worksheet


Sub SaveCopy()


'saving a copy

sCampaignName = "Campaign Results: " & Control.Range("E3").Value & " " & Format(Now, "yy-mm-dd") & ".xls"

sFileName = Application.GetSaveAsFilename("sCampaignName", "Excel 97-2003 workbook (*.xls),*.xls", 1)

If sFileName = "False" Then Exit Sub


ActiveWorkbook.SaveAs sFileName, xlExcel8


End Sub
 
Premsivakanthan

Try removing the : from the sCampaignName = line
 
Hi Hui, essentially what I'm trying to do is specify the filename, but allow the user to choose the file location, which is why I have created the sCampaignName variable.
 
Premsivakanthan


You cannot use a : in a file name

So remove the : and you should be ok

Maybe replace it with a - character
 
oh so simple...and thats why you're a ninja...! thanks heaps, I was racking my brain so hard trying to get it to work, and I was stumped as I had used getsaveas many times before!
 
Back
Top