试图将标题串起来就足以成为一种挑战......
我试图从PowerShell运行一些PowerPoint宏.我已经非常擅长从Powershell for Excel运行宏.当我在Excel上运行宏时,COM对象的Run()方法将采用各种参数,具体取决于宏是否有任何参数.但另一方面,PowerPoint Run()方法需要参数,我无法弄清楚如何传递它们.
我的宏期待通过一个字符串,我已经大量搜索并且缩短了.我总是得到这个错误:
错误:
type must not be ByRef
Run Code Online (Sandbox Code Playgroud)
我在PowerShell中整理了一个非常基本的PoC for PowerPoint:
码:
# PowerPoint test
Add-type -AssemblyName office
$PowerPoint = New-Object -comobject PowerPoint.Application
$PowerPoint.Visible = [Microsoft.Office.Core.MsoTriState]::msoTrue
$presentation2 = $PowerPoint.Presentations.open("C:\macros.pptm")
$presentation = $PowerPoint.Presentations.open("C:\Test For Macros.pptx")
$PowerPoint.run("macros.pptm!IAM",[ref]"Feb")
$presentation.save()
$presentation.close()
$presentation2.close()
$PowerPoint.quit()
# extra clean up omitted
Run Code Online (Sandbox Code Playgroud)
宏本身只是在框中移动一些文本,从PowerPoint运行时它可以正常工作.
需求:
我现在想要跨多个文件和幻灯片自动执行此操作.
有关PowerPoint COM对象的文档运行方法,显示了两个参数的要求.
我想在PowerShell中使用特定应用程序的cmdln打开一个文件.
在我的情况下,我有一个文件scripts.js,我想打开Notepad++但notepad.exe如果我这样做,通常会定期打开:Invoke-Item .\scripts.js
我应该怎么做才能打开该文件Notepad++?
我正在使用copyToClipboard我的应用程序.除IE和Firefox外,它在Chrome和Firefox浏览器中运行良好.
在IE (特别是版本11)中,单击" 复制"时,它会引入本机浏览器弹出窗口,询问"允许"或"拒绝",并且还会滚动到页面底部.
弹出窗口介绍很好,但我需要停止向下滚动.
码:
$scope.copyData = function(id) {
var copyAreaObject = document.createElement('textarea');
$scope.copyInitialize(id, copyAreaObject);
var selector = document.querySelector('#copyWrapper');
selector.select();
document.execCommand('copy');
document.body.removeChild(copyAreaObject);
};
Run Code Online (Sandbox Code Playgroud)