Workbook in attachement of Email - specific Xls format . How to ?

Misterbean

New Member
Joined
Jan 28, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi dear Community,
I am beginner in Excel VBA and found my way to send a (.xlsm ) workbook in attachment of an email but I struggle with the format since I have to send it in .xlsx format to recipient when the workbook I am working initially is a .xlsm. I also created (in the same macro) an automatic save in specific Path , enabling me to save a copy in .xlsx format. great !

So my question is how may I set in Email attachement the .xlsx version and not the orginal .xlsm one ? - I guess I have to work on the section highlighted in red in the code below ?

Your feedback is highly appreciated
MB0


Here is the code :

Sub SendEmailSave2Path()
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim ws As Worksheet

' Set the workbook and worksheet you want to send
Set wb = ThisWorkbook ' The current workbook
' Create a new Outlook instance
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0) ' 0 represents a mail item

' Compose the email
With OutMail
.To = "" ' Replace with the recipient's email address
.Subject = "My Subject title_" ' Replace with your email subject
.Body = "Hi ," & "Kind regards"
.Attachments.Add wb.FullName ' Attach the entire workbook
.display


End With

' Clean up

Set OutMail = Nothing

Set OutApp = Nothing

Dim MyFilePath As String
Dim MyFileName As String
MyFilePath = "C:\Users\Documents"
MyFileName = "MOR_"
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & MyFileName & ".xlsx"

End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Send workbook with specific format ... how to ?
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,951
Members
449,095
Latest member
nmaske

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