2013-12-17 95 views
0

我们最近从Office 2003升级到Office覆盖分享/邮件/保存附件在Excel 2013 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用自定义宏?

回答

0

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