简体   繁体   English

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

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

We have recently upgraded from Office 2003 to Office 365. 我们最近已从Office 2003升级到Office 365。

I used to override the File/Send feature with a macro that would check whether the current file was a confidential company file (by name). 我曾经用一个宏覆盖File/Send功能,该宏将检查当前文件是否为机密公司文件(按名称)。 If it was then it would block the send. 如果是这样,它将阻止发送。 If it wasn't then it would open an email with the file attached. 如果不是,那么它将打开带有附件的电子邮件。

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

How do I do the same thing in Excel 2013 - to override the Share/Email/Save as Attachment in Excel 2013 with a custom macro ? 如何在Excel 2013中执行相同操作-使用自定义宏覆盖Excel 2013中的Share/Email/Save as Attachment

It seems to me that this is impossible. 在我看来,这是不可能的。 The only thing possible seems to me to be is to add the code functionality to a button on an addin, and ask the users to use this button to send the email 在我看来,唯一可能的是将代码功能添加到插件上的按钮,并要求用户使用此按钮发送电子邮件。

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

相关问题 Excel Macro以保存Outlook 2010附件,将最早的电子邮件保存为最新的电子邮件 - Excel Macro to Save Outlook 2010 attachment, oldest email to newest email 将 jpg 保存为附件的 Excel 宏 - Excel macro to save jpg as attachment 如何使用excel vba宏保存ut8编码 - How do I save ut8 encoding with excel vba macro 使用Python运行宏后如何保存Excel工作簿? - How do I save Excel Workbook after running macro with Python? 如何在Excel 2013中的单个单元格上具有多种条件格式而不使用宏 - How do I have Multiple Conditional formats on a single cell in excel 2013 without using a macro 如何将 Python 数据帧存储在内存中并将其作为 excel 附件发送到特定的电子邮件地址? - How do I store Python dataframe in-memory and send it as excel attachment to specific email addresses? 如何将 Excel XLS gmail email 附件中的数据导入覆盖现有数据的 Google 表格 - How do I import data from an Excel XLS gmail email attachment into a Google Sheet that overwrites the existing data 自动从电子邮件下载附件并将其保存到 Excel - Download and Save Attachment from Email Automatically to Excel 将电子邮件附件保存到Excel文件损坏文件 - Save email attachment to excel file corrupts file 如何使此Excel宏以.xls(Excel 97-2003)格式保存,而不是.xlsx? - How do I make this Excel macro save in .xls (Excel 97-2003) format, instead of .xlsx?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM