Automatically Email worksheet when saved

Agbrooker

New Member
Joined
Nov 28, 2017
Messages
4
Hi all

I hope you can help me, I have managed to make my workbook automatically send an email when the workbook is saved using the code below, however the only problem is that the selection on the email is massize and spreads across 2-3 pages, meaning that it can not be printed, can I add something somewhere that will reduce the size of the selection in the email?

Thanks

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)


Sheets("Requisition").Range("A1:J32").Select '#
ActiveWorkbook.EnvelopeVisible = True

With ActiveSheet.MailEnvelope
.Introduction = "Hello, Spares Requisition Updated! - the workbook was Updated by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
.Item.To = "xxx@xxx.com;
.Item.Subject = "Spares Request update Number "
.Item.display
'.Item.send
End With


End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

I may be way off base here but have you tried setting the print area in the workbook prior to saving it?
 
Upvote 0
Hello again,

I tried your code with some test data and when I make the data stay within one page break it emails and looks just fine. When I introduce additional page breaks it appears to behave the way you describe. I recommend looking at the Page Break Preview and Page Layout views in the View ribbon to verify your sheet looks the way you want it emailed.
 
Upvote 0
Thanks again, the workbook is set up to be one page but the page preview on the email is just to big. Thanks for your help though.

Regards
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top