我需要确定对Excel电子表格所做的更改,并将这些更改通过电子邮件发送给另一组。我对VBA的经验很少。进行更改后,我的电子表格能够发送电子邮件,但我希望将这些更改添加到电子邮件正文中。谢谢!
发送电子邮件-这是一个Workbook_BeforeClose
事件
Sub SendEmail()
Dim myMsg As Object
Set myMsg = CreateObject("CDO.Message")
Dim conadd As String
conadd = "http://schemas.microsoft.com/cdo/configuration/"
Dim strSender As String, strLocation As String
'Send mail
With myMsg
.To = "**********.com"
.FROM = "**********.com"
.Subject = "CWPL Has Been Updated"
.TextBody = "Please check the CWPL to identify the update and if it currently applies to us."
With .Configuration.Fields
.Item(conadd & "sendusing") = 2
.Item(conadd & "smtpserver") = "**********.com"
.Item(conadd & "smtpserverport") = 25
.Update
End With
.Send
End With
ExitFunc:
Set myMsg = Nothing
Exit Sub
Err:
MsgBox "There was a problem sending the CWPL Update message to Fusion Group", vbInformation, "CWPL Update Message Complete"
GoTo ExitFunc
End Sub
已添加 Debug.Print“新值”&target.Address(0,0).Value 但是我收到编译错误:无效的限定符 地址是罪魁祸首。...
也-这是Worksheet_Change代码
Private Sub Worksheet_Change(ByVal target As Range)
Dim KeyCells As Range
Set KeyCells = Range("A1:D1000")
If Not Application.Intersect(KeyCells, Range(target.Address)) _
Is Nothing Then
Debug.Print "Cells that changed: " & target.Address(0, 0), _
End If
结束子