A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook Execute Macro using Costume Control



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 20th 06, 02:54 PM posted to microsoft.public.outlook.program_vba
Andy via OfficeKB.com
external usenet poster
 
Posts: 1
Default Outlook Execute Macro using Costume Control

Having read some of the postings on this website, I have managed to define my
own custom button 'HSE Monitors' on the 'Main Menu' commandbar. However, I
have not been able set-up the command button to execute the required macro.
The required macro being 'SaveAttachment' in the 'ThisOutlookSession' module.

Can anyone help. I have listed the code I have tried so far. I am using
Excel 2000.

Private Sub Application_Startup()

Dim objOL As Outlook.Application
Dim colCB As Office.CommandBars
Dim objCB As Office.CommandBar
Dim objCBMenu As Office.CommandBarPopup
Dim objCBMenuCB As Office.CommandBar
Dim objCBB As Office.CommandBarButton

Set objOL = CreateObject("Outlook.Application")
Set colCB = objOL.ActiveExplorer.CommandBars
Set objCB = colCB.Item("Menu Bar")

For Each Control In objCB.Controls
If Control.Caption = "HSE Monitors" Then GoTo ByPass
Next Control

Set objCBMenu = objCB.Controls.Add(Type:=msoControlPopup, Temporary:=True)


With objCBMenu
.Caption = "HSE Monitors"
Set objCBMenuCB = .CommandBar
Set objCBB = objCBMenuCB.Controls.Add(Type:=msoControlButton,
Temporary:=True)
objCBB.Caption = "Check Monitor Emails"
objCBB.OnAction = "ThisOutlookSession.SaveAttachment"
End With

ByPass:

Set objButton = Nothing
Set objBar = Nothing

Set objOL = Nothing
Set colCB = Nothing
Set objCB = Nothing
Set objCBMenu = Nothing
Set objCBMenuCB = Nothing
Set objCBB = Nothing

End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200609/1

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding a Control to an ADODC Control, Is it possible Andrew Sampels Outlook - Using Forms 1 August 8th 06 10:02 PM
How can I run a macro from a custom button control AA Outlook - Using Forms 1 June 20th 06 10:35 PM
Execute rules with a macro Gerd Neumann Outlook and VBA 1 May 11th 06 09:50 PM
Command Failed to Execute JAYDEEP DESAI Outlook Express 1 April 6th 06 01:23 PM
Outlook 2002 Execute Files Sylvia Outlook - General Queries 2 April 6th 06 04:02 AM


All times are GMT +1. The time now is 10:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.