繁体   English   中英

如何使用自定义宏在Excel 2013中覆盖共享/电子邮件/另存为附件

[英]How do I override the Share/Email/Save as Attachment in Excel 2013 with a custom macro

我们最近已从Office 2003升级到Office 365。

我曾经用一个宏覆盖File/Send功能,该宏将检查当前文件是否为机密公司文件(按名称)。 如果是这样,它将阻止发送。 如果不是,那么它将打开带有附件的电子邮件。

Sub sendme()
    aName = ActiveWorkbook.Name
    Flag = True
    If InStr(UCase(aName), "CONFIDENTIAL FILE") Then Flag = False
    If Flag = False Then MsgBox "You are trying to email " + aName + ".  This action has been blocked.", vbCritical: End
    Mail_with_outlook
End Sub

Sub Mail_with_outlook()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strto As String
    Dim strcc As String
    Dim strbcc As String
    Dim strsub As String
    Dim strbody As String
    Dim sh As Worksheet

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)

    If InStr(ActiveWorkbook.FullName, "\") = 0 Then
        MsgBox "Please save workbook before continuing", vbCritical
        End
    End If


    strto = ""
    strsub = ""
    strbody = "Special signature"

    With OutMail
        .To = strto
        .CC = strcc
        .BCC = strbcc
        .Subject = strsub
        .Body = strbody
        .Attachments.Add ActiveWorkbook.FullName
        .Display
    End With

End Sub

如何在Excel 2013中执行相同操作-使用自定义宏覆盖Excel 2013中的Share/Email/Save as Attachment

在我看来,这是不可能的。 在我看来,唯一可能的是将代码功能添加到插件上的按钮,并要求用户使用此按钮发送电子邮件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM