copy worksheet export as file and then email

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
741
Office Version
  1. 365
Platform
  1. Windows
hi
i have code that copies a specific worksheet then files it
how do I add: attach a copy of this new workbook and email it
Rich (BB code):
'Save New WB
        NewWB.SaveAs QBExportFolder & "QB Export " & Format(ReportMonth, "m_d_yyyy") & ".xlsx", 51
        NewWB.Close SaveChanges:=False
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
hi
it didnt fail it created the email but the attachment was NOT attached
there must be some other error
 
Upvote 0
where is the wbFile identified as the sAttachment?

These lines:

VBA Code:
        wbFile = NewWB.FullName


        Call QBExportEmailAccountant(CStr(Format(ReportMonth, "mmmm yyyy")), wbFile)


Sub QBExportEmailAccountant(ReportMonth As String, sAttachment As String)


    Call SendMailAccountant(sMail, sSubj, sBody, sAttachment)


Sub SendMailAccountant(sMail, sSubj, sBody, sAttachment)


    .Attachments.Add sAttachment
I would step through the code with F8 and check it.
 
Upvote 0
thanks so much
it works now. in F8 i found my small error
have a wonderful day
 
Upvote 0

Forum statistics

Threads
1,225,482
Messages
6,185,253
Members
453,283
Latest member
Shortm88

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