在powershell中操作已经运行的excel实例
好的,所以我从一个从PowerShell启动的实例中打开了一个工作簿:
$browser = new-object -ComObject "InternetExplorer.Application" $browser.navigate("url")
我从url下载/打开工作簿,但我想用运行脚本来操作它。 我想知道如果我能够从进程ID创build一个新的COM对象:
(Get-Process excel | Where-Object {$_.MainWindowTitle -like "*titleOFdownloadedEXCELwb*"}).id
有人能指点我的方向吗? 谢谢。
$xl = [Runtime.Interopservices.Marshal]::GetActiveObject('Excel.Application')
将定位活动的Excel实例(如果存在)。