2013-12-17 144 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

在我看來,這是不可能的。我認爲唯一可能的做法是將代碼功能添加到插件上的按鈕,並要求用戶使用此按鈕發送電子郵件