dave3009
Well-known Member
- Joined
- Jun 23, 2006
- Messages
- 7,142
- Office Version
- 365
- 2021
- Platform
- Windows
- Mobile
- Web
Hi Folks
I have managed to conjure up some code that will copy the current sheet from a given workbook, paste it to it's very own workbook, save it then e-mail it via Outlook.
see my code
Now this works, my only issue is that I get prompted if I want to Allow or Deny Outlook to send it. Ideally I'd want to just Allow as the end users are button pressers and may panic given an option.
In the above code I tried DisplayAlerts but that didn't do the trick.
Any help is much appreciated
Thanks
Dave
p.s. If I could save the file with the name Report plus a date time stamp I'd be doubly thankful
I have managed to conjure up some code that will copy the current sheet from a given workbook, paste it to it's very own workbook, save it then e-mail it via Outlook.
see my code
Code:
Sub testpastecode()
Dim iTemp As Long
Dim Fpath, CrName As String
iTemp = Application.SheetsInNewWorkbook
Fpath = ThisWorkbook.Path
CrName = ThisWorkbook.Name
Application.SheetsInNewWorkbook = 1
Workbooks.Add
ActiveWorkbook.SaveAs Fpath & "\Report.xls"
Workbooks(CrName).ActiveSheet.Cells.Copy
Application.DisplayAlerts = False
With ActiveWorkbook
.ActiveSheet.PasteSpecial
.ActiveSheet.Name = Workbooks(CrName).ActiveSheet.Name
.ActiveSheet.Range("A1").Select
.Save
.SendMail Recipients:="Dave3009"
End With
Application.DisplayAlerts = True
Application.SheetsInNewWorkbook = iTemp
Application.CutCopyMode = False
End Sub
Now this works, my only issue is that I get prompted if I want to Allow or Deny Outlook to send it. Ideally I'd want to just Allow as the end users are button pressers and may panic given an option.
In the above code I tried DisplayAlerts but that didn't do the trick.
Any help is much appreciated
Thanks
Dave
p.s. If I could save the file with the name Report plus a date time stamp I'd be doubly thankful