Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Good morning.
I'm working on this stuff with the help of the macro recorder. But clearly it's not exaustive for specific needs.
I've a workbook named "source".
Starting from a sheet named "last" of this workbook, I've to generate a new workbook with some datas and sending it in csv format to e-mail adresses via Microsoft Outlook.
This is my work with the macro recorder.
Furthermore, I've to name the new workbook using one cell of the "source" workbook. The cell is B2 in a sheet called "test".
The e-mail adresses that have to receive the mail are: "frank@example.com" and "mark@example.com"
Thank you.
I'm working on this stuff with the help of the macro recorder. But clearly it's not exaustive for specific needs.
I've a workbook named "source".
Starting from a sheet named "last" of this workbook, I've to generate a new workbook with some datas and sending it in csv format to e-mail adresses via Microsoft Outlook.
This is my work with the macro recorder.
Code:
Sub sent_mail()
Workbooks.Add 'open a new workbook'
Sheets("Sheet2").Select 'delete useless sheets, maybe not necessary'
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete
ChDir "C:\Users\john.smith\Desktop"
ActiveWorkbook.SaveAs Filename:="C:\Users\john.smith\Desktop\example.csv" _
, FileFormat:=xlCSV, CreateBackup:=False 'save with name example'
Windows("source.xlsm").Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy 'copy needed datas'
Windows("example.csv").Activate
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False 'past needed datas on csv new workbook'
Application.CutCopyMode = False
Application.Dialogs(xlDialogSendMail).Show
End Sub
Furthermore, I've to name the new workbook using one cell of the "source" workbook. The cell is B2 in a sheet called "test".
The e-mail adresses that have to receive the mail are: "frank@example.com" and "mark@example.com"
Thank you.
Last edited: