Hi. I have a simple macro that works fine in VBA within Outlook – I store it in VBAProject.OTM. The problem is, when I distribute this, end-users must set the security to LOW. I also have to override menu items by modifying outcmd.dat.
The solution is for me to create a COM AddIn, which I am doing with VBA6.
I have code samples from Professional Outlook 200 Programming (Slovak, Burhham, Gifford). The dll works perfectly – It adds menu items and buttons.
When I run this EXACT CODE in Outlook VBA, the menu and buttons are created AND they also run the simple macros. But once in the DLL, the buttons do not run the macros. I’ve even stripped down the macro to just a msgbox with still no luck. It’s as if the DLL has shut down after its initial run. (It runs on Outlook start up, because I can get the menus to add, and even the test sub msgbox macro to run.) Could this be a security issue? But then why would it be allowed to run on startup but then fail?
THANKS,
MARCIO SERRAO
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Outlook COM ADD IN (Office XP VBA6)
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Outlook COM ADD IN (Office XP VBA6)
- This topic has 10 replies, 4 voices, and was last updated 20 years, 10 months ago.
AuthorTopicWSMarcioSerrao
AskWoody LoungerApril 9, 2004 at 10:08 pm #403498Viewing 3 reply threadsAuthorReplies-
WSjscher2000
AskWoody LoungerApril 9, 2004 at 10:53 pm #812750My only COM Add-in is designed to listen for the ID associated with the Insert>File command inside a message composition window. Thus, I haven’t had to create any commandbar controls.
What is your code to intercept the button presses? Mine is more or less as follows; I certainly do not claim that this is efficient, it was my first COM Add-in, my first event-handling project, and had to be done in my spare time in a matter of days.
And now that it works, I haven’t had much incentive to tinker with it. So, for what it’s worth:
Add-in Designer named WDX_OL
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ ByVal AddInInst As Object, custom() As Variant) ' set up event handler for new Inspectors Call HandleInspector End Sub
Class module named clsOL01
Public WithEvents NewInsp As Outlook.Inspectors Public WithEvents ActiveInsp As Outlook.Inspector Public WithEvents InsFile As CommandBarButton Private Sub NewInsp_NewInspector(ByVal Inspector As Inspector) 'main routine to re-route the button click 'only want to handle messages... If Inspector.CurrentItem.Class olMail Then Exit Sub 'initialize event handler class for this message Call SetIntercept(Inspector, 1079) End Sub Private Sub ActiveInsp_Activate() 'not sure if this runs, but just as a backup 'only want to handle messages... If ActiveInspector.CurrentItem.Class olMail Then Exit Sub 'initialize event handler class for this message Call SetIntercept(ActiveInspector, 1079) End Sub Private Sub InsFile_Click(ByVal Ctrl As Office.CommandBarButton, _ CancelDefault As Boolean) If AttachWDXFiles Then 'cancel the default Insert File dialog CancelDefault = True Else CancelDefault = False End If End Sub
Regular code module named OL01
Dim OLEvents As New clsOL01 Sub HandleInspector() 'initialize event handler for a new inspector (mail or otherwise) Set OLEvents.NewInsp = Outlook.Inspectors 'when new insp created Set OLEvents.ActiveInsp = Outlook.ActiveInspector 'when insp activated End Sub Sub SetIntercept(myInsp As Inspector, intID As Integer) Dim ctlBtn As CommandBarButton Set ctlBtn = myInsp.CommandBars("Standard").FindControl(Id:=intID) Set OLEvents.InsFile = ctlBtn End Sub Function AttachWDXFiles() As Boolean ...details omitted... End Function
Too bad it doesn’t work for users who use Word as their mail editor….. Hope this helps.
-
WSjscher2000
AskWoody LoungerApril 9, 2004 at 10:53 pm #812751My only COM Add-in is designed to listen for the ID associated with the Insert>File command inside a message composition window. Thus, I haven’t had to create any commandbar controls.
What is your code to intercept the button presses? Mine is more or less as follows; I certainly do not claim that this is efficient, it was my first COM Add-in, my first event-handling project, and had to be done in my spare time in a matter of days.
And now that it works, I haven’t had much incentive to tinker with it. So, for what it’s worth:
Add-in Designer named WDX_OL
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ ByVal AddInInst As Object, custom() As Variant) ' set up event handler for new Inspectors Call HandleInspector End Sub
Class module named clsOL01
Public WithEvents NewInsp As Outlook.Inspectors Public WithEvents ActiveInsp As Outlook.Inspector Public WithEvents InsFile As CommandBarButton Private Sub NewInsp_NewInspector(ByVal Inspector As Inspector) 'main routine to re-route the button click 'only want to handle messages... If Inspector.CurrentItem.Class olMail Then Exit Sub 'initialize event handler class for this message Call SetIntercept(Inspector, 1079) End Sub Private Sub ActiveInsp_Activate() 'not sure if this runs, but just as a backup 'only want to handle messages... If ActiveInspector.CurrentItem.Class olMail Then Exit Sub 'initialize event handler class for this message Call SetIntercept(ActiveInspector, 1079) End Sub Private Sub InsFile_Click(ByVal Ctrl As Office.CommandBarButton, _ CancelDefault As Boolean) If AttachWDXFiles Then 'cancel the default Insert File dialog CancelDefault = True Else CancelDefault = False End If End Sub
Regular code module named OL01
Dim OLEvents As New clsOL01 Sub HandleInspector() 'initialize event handler for a new inspector (mail or otherwise) Set OLEvents.NewInsp = Outlook.Inspectors 'when new insp created Set OLEvents.ActiveInsp = Outlook.ActiveInspector 'when insp activated End Sub Sub SetIntercept(myInsp As Inspector, intID As Integer) Dim ctlBtn As CommandBarButton Set ctlBtn = myInsp.CommandBars("Standard").FindControl(Id:=intID) Set OLEvents.InsFile = ctlBtn End Sub Function AttachWDXFiles() As Boolean ...details omitted... End Function
Too bad it doesn’t work for users who use Word as their mail editor….. Hope this helps.
-
WSHoward Kaikow
AskWoody LoungerApril 10, 2004 at 3:22 am #812825The best two Outlook programming books are likely:
Sue Mosher’s Microsoft Outlook Programming (ISBN: 1-55558-286-9)
Randy Byrne’s Building Applications wit hMicrosoft Outlook version 2002(ISBN: 0-7356-1273-0). There was also an edition for version 2000.Both cover COM add-ins for Outlook.
-
WSHoward Kaikow
AskWoody Lounger -
WSMarcioSerrao
AskWoody LoungerApril 11, 2004 at 4:55 pm #813209Thanks. I just ordered Randy Byrne’s book from Amazon.
From a bit more looking around, I’ve found out that I need to use WITHEVENTS to catch the button click. I’ve found some sample code, but all of them bomb on some line or another. Even the built in code in the DESIGNER of VB6 doesn’t work in Outlook. Ugh.
Thanks. -
WSgellwood
AskWoody Lounger -
WSgellwood
AskWoody Lounger
-
-
WSMarcioSerrao
AskWoody LoungerApril 11, 2004 at 4:55 pm #813210Thanks. I just ordered Randy Byrne’s book from Amazon.
From a bit more looking around, I’ve found out that I need to use WITHEVENTS to catch the button click. I’ve found some sample code, but all of them bomb on some line or another. Even the built in code in the DESIGNER of VB6 doesn’t work in Outlook. Ugh.
Thanks.
-
-
WSHoward Kaikow
AskWoody Lounger
-
-
WSHoward Kaikow
AskWoody LoungerApril 10, 2004 at 3:22 am #812826The best two Outlook programming books are likely:
Sue Mosher’s Microsoft Outlook Programming (ISBN: 1-55558-286-9)
Randy Byrne’s Building Applications wit hMicrosoft Outlook version 2002(ISBN: 0-7356-1273-0). There was also an edition for version 2000.Both cover COM add-ins for Outlook.
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Sometimes I wonder about these bots
by
Susan Bradley
2 hours, 11 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
8 hours, 15 minutes ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
9 hours, 16 minutes ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
8 hours, 41 minutes ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
5 hours, 11 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
11 hours, 57 minutes ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
11 hours, 59 minutes ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
33 minutes ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
20 hours, 6 minutes ago -
0Patch, where to begin
by
cassel23
14 hours, 8 minutes ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
1 day, 9 hours ago -
89 million Steam account details just got leaked,
by
Alex5723
21 hours, 30 minutes ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
1 day, 18 hours ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
1 day, 9 hours ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
20 hours, 23 minutes ago -
Installer program can’t read my registry
by
Peobody
3 hours, 4 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
1 day, 7 hours ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
1 day, 14 hours ago -
False error message from eMClient
by
WSSebastian42
2 days, 5 hours ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
2 days, 14 hours ago -
Office 2021 Perpetual for Mac
by
rebop2020
2 days, 15 hours ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
2 hours, 20 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
2 days, 19 hours ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
2 hours, 39 minutes ago -
Outdated Laptop
by
jdamkeene
3 days ago -
Updating Keepass2Android
by
CBFPD-Chief115
3 days, 6 hours ago -
Another big Microsoft layoff
by
Charlie
3 days, 5 hours ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
7 hours, 52 minutes ago -
May 2025 updates are out
by
Susan Bradley
9 hours, 34 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
3 days, 11 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.