Here's my code, it is almost exactly the same as the code posted by Gareth Horton.
Private Sub wopgOpen()
Monarch_Launch 'Call the Monarch_Launch sub
Do While IsServerActive() 'Keep checking to see if server is active
DoEvents 'Allows you to do other tasks
'Clean up by closing all open documents
'Send Monarch the exit command
'Destroy the object - completing a nice clean exit procedure
Set Monarchobj = Nothing
Dim openfile, openmod As Boolean
Dim Setwin As Boolean
Dim serveron, Winsize As Integer
'Check to see if the server is active (Monarch is open)
serveron = IsServerActive()
'If server is not active then create it
If serveron = 0 Then
Set Monarchobj = CreateObject("Monarch32")
'Set Monarch to open in the table window
Setwin = Monarchobj.SetFirstView("T")
'Open the report and model file
openfile = Monarchobj.setreportfile("S:steve_r cmstock2003P09wopg9.txt", False)
If openfile = True Then
openmod = Monarchobj.setmodelfile("S:steve_rMonarchModelsWOPG.mod")
On Error GoTo NoServer
If Monarchobj.IsActive > 0 Then 'Check to see if server is active
IsServerActive = 1
IsServerActive = 0 'Trap the error when the server is inactive
End Function[/font][/quote]Thanks again
There's only one line of code needed to make this work, and Gareth's example didn't have it either, so don't feel too frustrated. You need to declare your Monarch object as a global variable before the code for the subroutines.
Public Monarchobj as Object
as the first line in your module.
Worked for me. Let us know if this resolves the problem.
[size="1"][ October 09, 2003, 05:39 PM: Message edited by: Data Kruncher ][/size]