Date: Tue, 21 Nov 2006 12:36:47 -0500
Reply-To: Graham Murray <graham.murray@WEBMINER.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Graham Murray <graham.murray@WEBMINER.CO.UK>
Subject: Re: VBA - SAS IOM/ Integration Tech question
Thanks for the reply Roy.
Problem is I can't get the normal module code to run the event handler
when an event is triggered.
In Sheet code:
Public WithEvents obLS As SAS.LanguageService
Sub obLS_StepError()
' An error has occurred. Dump the log
Debug.Print "Event Call"
End Sub
In Module bit:
Public obWSM As New SASWorkspaceManager.WorkspaceManager
Public obWS As SAS.Workspace
Public obWSflag As Integer
Dim obLS As SAS.LanguageService
Sub Main()
' Set up SAS Connection
MakeConnection
Debug.Print "Before Submit"
Set obLS = obWS.LanguageService
' Deliberately execute a syntax error to trap an error
obLS.Submit "proc x;run;"
Debug.Print obLS.FlushLog(10000)
CloseConnection
Debug.Print "After Conn closed"
End Sub
Doesn't go anywhere near the event handler ....
Any suggestions ?
Thanks Again ....
On Tue, 21 Nov 2006 08:59:35 -0800, Pardee, Roy <pardee.r@GHC.ORG> wrote:
>This compiles for me in a 'sheet' module:
>
> Dim WithEvents y As SAS.LanguageService
>
>Once I write that, I get a 'y' entry in the left-hand drop-down box at
>the top of the code editor, and can select events like ProcStart,
>ProcComplete & StepError in the right-hand box, to write handlers for
>those events.
>
>VBA has 2 types of containers for code--plain old 'modules', which is
>where you put code you want to be able to call from most anyplace, and
>'class modules', which are intended to hold the definitions of 'objects'
>in an OOP sense. Like the error message says, the event wireup stuff
>only works in object (class) modules. Modules hanging off worksheets
>count as class modules, so it should work there. You can also create
>your own class module in a project by choosing it off the Insert menu.
>
>HTH,
>
>-Roy
>