PDA

View Full Version : SAVEAS with location



reneeebjames
12-08-2016, 10:14 AM
I am trying to have this file save on the desktop because several people will use the file. I have tried added the location when I do the wbNam and in ActiveWorkbook.SaveAs both give me a run-time error of 1004. :wot

Any suggestions?


Sub datetime()
Dim dt As String, wbNam As String
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
' Saving file with time stamp
wbNam = "TheBeast_"
dt = Format(CStr(Now), "yyyy_mm_dd_hhmm")
ActiveWorkbook.SaveAs Filename:=wbNam & dt
' Change the mail address and subject in the code before you run it.
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Test"
.Body = " Can't believe it is taking this long "
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

p45cal
12-08-2016, 06:07 PM
To save to the user's desktop, replace your SaveAs line to:
ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator & wbNam & dt