How to get the process ID of the current Excel instance, through VBA, without using the caption?

前端 未结 3 2208
无人共我
无人共我 2021-02-20 03:38

How can I get the process ID of the current Excel instance that my VBA code is running in? I don\'t want to asking for it by the name in the caption, which causes problems when

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-20 04:14

    My solution in Excel 2013: in a new module, I added the following code:

    Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
    
    Public Sub Test()
        Debug.Print GetCurrentProcessId
    End Sub
    

提交回复
热议问题