Tường_Vi
Thành viên tiêu biểu

- Tham gia
- 19/4/10
- Bài viết
- 482
- Được thích
- 121
- Nghề nghiệp
- Luôn tìm kiếm một vị trí tốt hơn
Em xin hỏi code nào chuyển sheet1.Page1 (trang 1 của sheet 1) thành 1 file PDF có tên là Test001 không?
Sau đó mình sẽ gửi mail File Test001 đến 1 hoặc nhiều địa chỉ mail cho trước
(mail gửi bằng MO Outlook 2007)
Về đoạn code gửi mail 1 sheet excel em sưu tầm được code này
Sau đó mình sẽ gửi mail File Test001 đến 1 hoặc nhiều địa chỉ mail cho trước
(mail gửi bằng MO Outlook 2007)
Về đoạn code gửi mail 1 sheet excel em sưu tầm được code này
PHP:
Sub EmailWithOutlook()
'Variable declaration
Dim oApp As Object, _
oMail As Object, _
WB As Workbook, _
FileName As String
'Turn off screen updating
Application.ScreenUpdating = False
'Make a copy of the active sheet and save it to
'a temporary file
ActiveSheet.Copy
Set WB = ActiveWorkbook
FileName = "Test_" & Trim(ActiveSheet.Name) & ".xls"
On Error Resume Next
Kill "C:\" & FileName
On Error GoTo 0
WB.SaveAs FileName:="C:" & FileName
'Create and show the outlook mail item
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
'Uncomment the line below to hard code a recipient
.To = Sheet1.Range("k3") ' gui dia chi mail toi nhung nguoi tai cell K3
'Uncomment the line below to hard code a subject
.Subject = "Test " & Sheet1.Range("K2") ' tao ten file
.Attachments.Add WB.FullName
.Display
End With
'Delete the temporary file
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName
WB.Close SaveChanges:=False
'Restore screen updating and release Outlook
Application.ScreenUpdating = True
Set oMail = Nothing
Set oApp = Nothing
End Sub
Lần chỉnh sửa cuối: