[dba-VB] CreateObject, GetObject Functions

Bryan Carbonnell Bryan_Carbonnell at cbc.ca
Thu May 13 08:18:38 CDT 2004


Adam,

Here is how I deal with this:

  'Temporarily disable error handling
  On Error Resume Next
  'Get a reference to an already open session on Excel
  Set objXL = GetObject(, "Excel.Application")
  'Check to see if everything is ok
  If objXL Is Nothing Then
    'Object is nothing, which means Excel is not open
    Set objXL = CreateObject("Excel.Application")
    bolWeLoaded = True
  End If
  
  'Restore proper error handling
  On Error GoTo cmdExcel_Click_Error


Bryan Carbonnell
bryan_carbonnell at cbc.ca

>>> AdamB at peabody.org.uk 13-May-04 9:10:47 AM >>>
Question:

I am trying to set the value of a Boolean variable on the basis of
whether
an instance of Excel is running.  In doing this I can then determine
whether
to perform a CreateObject or GetObject function.

Do any of you have any suggestions.



More information about the dba-VB mailing list