cheking if there si an excel process, and use it to open int this instance a book


I´m looking for the way to look if there is an excel instance activate to use after thisone to open a book, and not open then a new excel instance.

Who is Participating?
Hello 1469,

you could use the code GetObject
Dim xlApp as Object
'use a resume next to prevent an error dialog
on error resume next
'try to get the running excel
Set xlApp = GetObject(,"Excel.Application" )
'now we get an error but the resume next is going to the next line
if xlApp is Nothing then
  'if there is no excel running create one
  Set xlApp = CreateObject("Excel.Application" )
end if

hope this helps a bit
Éric MoreauSenior .Net ConsultantCommented:
Hi 1469,

you need to use GetObject. See for a sample

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.