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, 11 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
-
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
22 minutes ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
23 minutes ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
6 hours, 15 minutes ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
7 hours, 14 minutes ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
1 minute ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
19 hours, 22 minutes ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
8 hours, 54 minutes ago -
System Restore and Updates Paused
by
veteran
21 hours, 53 minutes ago -
Windows 10/11 clock app
by
Kathy Stevens
8 hours, 58 minutes ago -
Turn off right-click draw
by
Charles Billow
1 day, 1 hour ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
1 day, 4 hours ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
6 hours, 33 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
1 day, 6 hours ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
9 hours, 7 minutes ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
1 day, 12 hours ago -
KB5060842 Issue (Minor)
by
AC641
21 minutes ago -
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
1 day, 19 hours ago -
24H2 may not be offered June updates
by
Susan Bradley
11 hours, 58 minutes ago -
Acronis : Tracking Chaos RAT’s evolution (Windows, Linux)
by
Alex5723
2 days, 7 hours ago -
June 2025 updates are out
by
Susan Bradley
6 hours, 24 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
2 days, 22 hours ago -
Windows-Maintenance-Tool (.bat)
by
Alex5723
2 days, 8 hours ago -
Windows 11 Insider Preview build 26200.5641 released to DEV
by
joep517
3 days, 1 hour ago -
Windows 11 Insider Preview build 26120.4250 (24H2) released to BETA
by
joep517
3 days, 1 hour ago -
Install Office 365 Outlook classic on new Win11 machine
by
WSrcull999
3 days, 1 hour ago -
win 10 to win 11 with cpu/mb replacement
by
aquatarkus
2 days, 17 hours ago -
re-install Windows Security
by
CWBillow
3 days, 4 hours ago -
WWDC 2025 Recap: All of Apple’s NEW Features in 10 Minutes!
by
Alex5723
3 days, 8 hours ago -
macOS Tahoe 26
by
Alex5723
3 days, 2 hours ago -
Migrating from win10 to win11, instructions coming?
by
astro46
17 hours, 5 minutes 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.