Thursday, April 21, 2011

How to get the process ID of the current Excel, throught VBA, without relying on finding the window by the caption?

How can I get the process ID of the current Excel instance, that my VBA code is running in, without asking for it by the name in the caption... which causes a problem when I have two or more Excel instances with the same caption?

From stackoverflow
  • You can use this method to get the current process id.

    Declare Function GetCurrentProcessId Lib "kernel32" () As Long
    

    This page has a good overview of exactly how you can do it in various versions of excel.

  • thanks very much Its helped me in time..

0 comments:

Post a Comment