我在后台运行Outlook。使用Excel 2010。
我想做以下事情:
我有以下内容:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim APP_OUTLOOK As Object
Dim MESSAGE As Object
Set APP_OUTLOOK = CreateObject("Outlook.Application")
Set MESSAGE = APP_OUTLOOK.CreateItem(0)
If Not Intersect(Target, Range("A1:A1048576")) Is Nothing Then
With MESSAGE
.To = "name.name@name.com"
.Subject = ""
.Body = "hey buddy, something has changed please have a look at cell: "
'the text should show: "hey buddy, something has changed please have a look at cell: A25000."
.Display
End With
End If
End Sub
在扎克的帮助下,我能够解决我的问题。
以下是工作代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim APP_OUTLOOK As Object
Dim MESSAGE As Object
Set APP_OUTLOOK = CreateObject("Outlook.Application")
Set MESSAGE = APP_OUTLOOK.CreateItem(0)
If Not Intersect(Target, Range("A1:A1048576")) Is Nothing Then
With MESSAGE
.To = "name.name@name.com"
.Subject = ""
.Body = "hey buddy," & vbNewLine & vbNewLine & "the file has been modified" & vbNewLine & vbNewLine & "following cell has a new entry: " & Target.Address & vbNewLine & vbNewLine & "the new entry has the value " & Target.Text & vbNewLine & vbNewLine & "please check the excel file" & vbNewLine & vbNewLine & "best wishes," & vbNewLine & "me"
.Display
End With
End If
End Sub
答案 0 :(得分:0)
我没有测试过您的代码,但它看起来应该可行。要更改单元格的地址,请在Target.Address
对帐单的末尾添加.Body