G
Georgie8888
Hi,
I am trying to use the following macro from Rondebruin's site, but am
encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas?
Also, is there a simpler way to get the email to open through Outlook,
rather than putting in server details (see below)?
The purpose of this macro is to open an email from Excel and Word and attach
the open document.
Thank you for your assistance
Georgie
Sub CDO_Send_Workbook()
Dim iMsg As Object
Dim iConf As Object
Dim wb As Workbook
Dim WBname As String
' Dim Flds As Variant
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
WBname = wb.Name & " " & Format(Now, "dd-mm-yy h-mm-ss") & ".xls"
wb.SaveCopyAs "C:/" & WBname
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
'
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in
your SMTP server here"
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
With iMsg
Set .Configuration = iConf
.Subject = "This is a test"
.TextBody = "This is the body text"
.AddAttachment "C:/" & WBname
End With
Set iMsg = Nothing
Set iConf = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
End Sub
I am trying to use the following macro from Rondebruin's site, but am
encountering an error at "wb.SaveCopyAs "C:/" & WBname". Any ideas?
Also, is there a simpler way to get the email to open through Outlook,
rather than putting in server details (see below)?
The purpose of this macro is to open an email from Excel and Word and attach
the open document.
Thank you for your assistance
Georgie
Sub CDO_Send_Workbook()
Dim iMsg As Object
Dim iConf As Object
Dim wb As Workbook
Dim WBname As String
' Dim Flds As Variant
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
WBname = wb.Name & " " & Format(Now, "dd-mm-yy h-mm-ss") & ".xls"
wb.SaveCopyAs "C:/" & WBname
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
'
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in
your SMTP server here"
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
With iMsg
Set .Configuration = iConf
.Subject = "This is a test"
.TextBody = "This is the body text"
.AddAttachment "C:/" & WBname
End With
Set iMsg = Nothing
Set iConf = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
End Sub