View Single Post
  #1  
Old January 6th 09, 08:23 PM posted to microsoft.public.outlook.program_vba
wpiet
external usenet poster
 
Posts: 19
Default Access Excel (whether already open or not) from Outlook

What am I doing wrong with this code?

Dim XL As Object

On Error Resume Next
Set XL = GetObject("Excel.Application")
If XL Is Nothing Then
Set XL = CreateObject("Excel.Application")
End If
XL.Visible = True

I was under the impression that, if an instance of Excel is already running,
GetObject would access it & 'Set' would assign it to the variable 'XL'.
However, when I step through it, 'XL' = Nothing & CreateObject opens
another instance of Excel.
--
Will
Ads