【问题标题】:On close Excel updated file send email or skype message using VBA在关闭 Excel 更新文件时使用 VBA 发送电子邮件或 Skype 消息
【发布时间】:2019-03-07 07:15:13
【问题描述】:

我需要 Excel VBA 代码,以便每当我关闭和更新 Excel 文件(文件中的数据必须已更新)时,向其他人发送 Skype 消息或电子邮件,说明该文件已更新。

我正在寻找可以实现此目的的 VBA 代码。

重要提示:该代码适用于 Skype 或 Mozilla Thunderbird。

【问题讨论】:

  • 您是否尝试过使用现有的替代方案?例如,像 Google 文档一样,您可以打开通知,如 here 所述

标签: excel vba email skype


【解决方案1】:

Here 是一篇很好的文章,其中包含 VBA 代码,介绍了如何在特定 Excel 工作表更新时发送电子邮件。

这是正在使用的代码:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim nConfirmation As Integer
    Dim objNewWorkbook As Excel.Workbook
    Dim objNewWorksheet As Excel.Worksheet
    Dim objOutlookApp As Object
    Dim objMail As Object

    nConfirmation = MsgBox("Do you want to send an email notification about the sheet updating now?", vbInformation + vbYesNo, "Mail Sheet Updates")

    If nConfirmation = vbYes Then
       ActiveWorkbook.Save

       On Error Resume Next
       Set objOutlookApp = CreateObject("Outlook.Application")
       Set objMail = objOutlookApp.CreateItem(olMailItem)

       'Change the email details as per your needs
       With objMail
           .To = "test@datanumen.com"
           .Subject = "Email Notifying Sheet Updates"
           .Body = "Hi," & vbCrLf & vbCrLf & "The worksheet " & Chr(34) & ActiveWorkbook.Sheets(1).Name & Chr(34) & " in this Excel workbook attachment is updated."
           'Attach this workbook
           .Attachments.Add ActiveWorkbook.FullName
           .Send
      End With
    End If
End Sub

它可以作为一个有用的起点。

【讨论】:

  • Skype 或电子邮件客户端 Thunderbird 有什么用吗?因为下面的 VBA 代码似乎是用于 Outlook 的。
  • 这对你来说可能是一个很好的作业;)关键字:SMTP
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-24
  • 2014-07-18
  • 2016-10-31
  • 1970-01-01
  • 2014-12-18
  • 2022-01-03
相关资源
最近更新 更多