Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2003, 08:19 AM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Outlook

Hi,

I've been looking all around the web for some examples of using VB with Outlook, and I've found something strange. There seems to be two common ways of doing what looks like the same thing:

Method 1
Public Sub Application_Startup()
' initialization code
End Sub

Private Sub Application_NewMail()
' code to run when new mail arrives, using Application object
End Sub


Method 2
Dim WithEvents myOlApp As Outlook.Application

Public Sub Application_Startup()
Set myOlApp = CreateObject("Outlook.application")
' initialization code
End Sub

Private Sub myOlApp_NewMail()
' code to run when new mail arrives, using myOlApp object
End Sub


Can someone please tell me what the difference is between these two chunks of code and what reasons there are to prefer one over the other? (If it matters, I'm using Outlook 2000.) Thanks!


-E.D.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook jdhock8865 Beginning VB 6 3 July 9th, 2008 12:01 PM
Outlook magicroy Excel VBA 0 July 25th, 2007 09:56 AM
Using Outlook JAnthony Access VBA 0 May 18th, 2006 03:13 PM
VB6 Outlook help Glyphed Beginning VB 6 3 March 21st, 2006 07:00 AM
Outlook Help ksrmramu Classic ASP Components 0 August 22nd, 2005 07:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.