|
楼主 |
发表于 2010-12-22 11:46
|
显示全部楼层
Private WithEvents vsoCommbandButton As CommandBarButton
Private WithEvents vsoCommbandReplyAllWithAttach As CommandBarButton
Private WithEvents colInspectors As Outlook.Inspectors
Private WithEvents vsoCommbandReplyAllWithAttachInspector As CommandBarButton
Private Sub Application_Startup()
Call addTotalButton
Set colInspectors = Application.Inspectors
End Sub
'增加工具栏
Sub addTotalButton()
'On Error Resume Next
Dim vsoCommandBar As CommandBar
'得到要添加的工具栏
Set vsoCommandBar = Outlook.ActiveExplorer.CommandBars("Point")
'如果工具栏为空,则增加
If (vsoCommandBar Is Nothing) Then
Set vsoCommandBar = Outlook.ActiveExplorer.CommandBars.Add("Point", msoBarTop)
'在工具栏上增加一个按钮
Set vsoCommbandReplyAllWithAttach = vsoCommandBar.Controls.Add(1)
vsoCommbandReplyAllWithAttach.Caption = "Send w/3&AS Coding"
vsoCommbandReplyAllWithAttach.FaceId = 68
vsoCommbandReplyAllWithAttach.Style = msoButtonIconAndCaption
'显示增加的工具栏
vsoCommandBar.Visible = True
Else
Set vsoCommbandReplyAllWithAttach = vsoCommandBar.Controls(1)
End If
End Sub
'得到当前选择的邮件
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
'On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
Private Sub vsoCommbandReplyAllWithAttach_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
'On Error Resume Next
Dim rpl As Outlook.MailItem
Dim itm As Object
Set itm = GetCurrentItem()
If Not itm Is Nothing Then
Set rpl = itm.ReplyAll
CopyAttachments itm, rpl
rpl.Display
End If
Set rpl = Nothing
Set itm = Nothing
End Sub
Sub colInspectors_NewInspector(ByVal Inspector As Inspector)
On Error Resume Next
Dim objCommandBar As CommandBar
Set objCommandBar = Inspector.CommandBars("Point")
If (objCommandBar Is Nothing) Then
Set objCommandBar = Inspector.CommandBars.Add("Point", msoBarTop, , True)
Set vsoCommbandReplyAllWithAttachInspector = objCommandBar.Controls.Add(msoControlButton, , , , True)
vsoCommbandReplyAllWithAttachInspector.Caption = "Send w/3&AS Coding"
vsoCommbandReplyAllWithAttachInspector.FaceId = 68
vsoCommbandReplyAllWithAttachInspector.Style = msoButtonIconAndCaption
objCommandBar.Visible = True
Else
Set vsoCommbandReplyAllWithAttachInspector = objCommandBar.Controls(1)
End If
End Sub
Private Sub vsoCommbandReplyAllWithAttachInspector_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
call 模块1.Application_ItemSend(ByVal Item As Object, Cancel As Boolean) '<<这里报错-“子过程或函数未定义”
CreateFile
End Sub |
|