-
SAVEAS with location
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.
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
-
To save to the user's desktop, replace your SaveAs line to:
ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator & wbNam & dt
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules