简体   繁体   English

使用Powershell自动化MSACCESS应用程序

[英]Automating a MSACCESS application with powershell

I want to be able to use the Sendwait function to automate a MS-ACCESS application using powershell commands. 我希望能够使用Powershell命令使用Sendwait函数来自动执行MS-ACCESS应用程序。 Unfortunately I haven't been able to get a handle in the usual way to the actual application window. 不幸的是,我无法以通常的方式获取实际应用程序窗口的句柄。 I can get a handle to MS-ACCESS itself, but attempts using Sendwait to automate the window failed. 我可以获取MS-ACCESS本身的句柄,但是尝试使用Sendwait自动执行窗口失败。

Any reason why you need to send keys? 您为什么需要发送密钥? Why not just use the methods and properties of the object in question. 为什么不只使用所讨论对象的方法和属性。

Just go: 去吧:

To launch Access, open a database, and then print a report, and then quit? 要启动Access,请打开数据库,然后打印报告,然后退出?

$Acc = New-Object –com Access.Application

$Acc.OpenCurrentDataBase("c:\t.accdb")
$Acc.docmd.OpenReport("rptCustomers")
$Acc.Quit()

So most if not all methods and properties of the Access application can be used via power-shell, and as a result, I don't think you need nor want to attempt using some type of send keys as that tends to be rather flakey and a poor way to automate things. 因此,大多数(如果不是全部)Access应用程序的方法和属性都可以通过Power-Shell使用,因此,我认为您不需要也不想尝试使用某种类型的发送密钥,因为这通常很容易出错,一种自动化的糟糕方法。 You might want to point out what commands or what you require, but you can also call VBA code this way, and as noted, even add records etc. 您可能想要指出什么命令或需要什么,但是您也可以以这种方式调用VBA代码,并且如上所述,甚至添加记录等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM