如何通过VBA获取当前Excel实例的进程ID,而不使用该标题? [英] How to get the process ID of the current Excel instance, through VBA, without using the caption?

查看:586
本文介绍了如何通过VBA获取当前Excel实例的进程ID,而不使用该标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取运行VBA代码的当前Excel实例的进程ID?我不想通过标题中的名称要求它,当我有两个或更多的具有相同标题的Excel实例时,会导致问题。

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 I have two or more Excel instances with the same caption.

推荐答案

您可以使用此方法获取当前进程标识。

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

Declare Function GetCurrentProcessId Lib "kernel32" () As Long

这个页面有一个很好的概述,你可以在各种版本的excel中如何做到这一点。

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

这篇关于如何通过VBA获取当前Excel实例的进程ID,而不使用该标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆