This thread is for those having Eudora and VB.
I have tested the code for Eudora both with and without AutoProtect and email
scanning disabled in Norton Auntie Virus 2003.
———————————————————————————-
I give two sets of code below.
a. One uses VB with Microsoft Word.
b. The other uses VB with Eudora.
You will need to have Eudora to replicate the behavior.
The only differences between the two sets of code are in the following:
1. Const strServerName
2. Dim app
3. Word uses app.Quit and Eudora uses app.CloseEudora.
The code works as expected when the target app is not running before
running the VB code.
If Word is already running when the VB code is run, the code works as
expected, i.e., Word is not shutdown.
However, if Eudora is already running, the VB code performs as expected the
first time the VB code is run, but running the VB code a second time causes
Eudora to shut down.
Can I code around such a problem?
Is this problem unique to Eudora?
Is there a property of GetObject that needs to be handled?
Here’s the two pieces of code:
'--------------------------------------------------------------------------- Option Explicit Sub main() ' If app is not running, create instance of app, do our thing, then close app. ' If app is already running, do our thing with running instance of app, and ' do not close app. Const strServerName As String = "Eudora.EuApplication.1" Dim app As EuApplication Dim blnCreated As Boolean Dim strPath As String On Error Resume Next blnCreated = False If app Is Nothing Then Set app = GetObject(, strServerName) If Err.Number 0 Then Err.Clear End If End If If app Is Nothing Then Set app = CreateObject(strServerName) If Err.Number 0 Then Err.Clear End If blnCreated = Not (app Is Nothing) End If If Not (app Is Nothing) Then strPath = app.Path End If On Error Resume Next If blnCreated Then app.CloseEudora End If Set app = Nothing End Sub '--------------------------------------------------------------------------- Option Explicit Sub main() ' If app is not running, create instance of app, do our thing, then close app. ' If app is already running, do our thing with running instance of app, and ' do not close app. Const strServerName As String = "Word.Application" Dim app As Word.Application Dim blnCreated As Boolean Dim strPath As String On Error Resume Next blnCreated = False If app Is Nothing Then Set app = GetObject(, strServerName) If Err.Number 0 Then Err.Clear End If End If If app Is Nothing Then Set app = CreateObject(strServerName) If Err.Number 0 Then Err.Clear End If blnCreated = Not (app Is Nothing) End If If Not (app Is Nothing) Then strPath = app.Path End If On Error Resume Next If blnCreated Then app.Quit End If Set app = Nothing End Sub