小编Chr*_*ris的帖子

通过PowerShell通过COM对象传递变量以在PowerPoint中运行宏

试图将标题串起来就足以成为一种挑战......

我试图从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 powerpoint vba powerpoint-vba

8
推荐指数
1
解决办法
999
查看次数

高级过滤条件是否可以在VBA而不是范围内?

在尝试通过VBA以正常的AutoFilter方式设置2个以上的标准之后,我得知它必须通过高级过滤器来完成.

冒犯的例子:

Worksheets(1).Range("A1").AutoFilter Field:=ColNum, Criteria1:="A*", Operator:=xlOr, Criteria2:="B*", Operator:=xlOr, Criteria3:="C*"
Run Code Online (Sandbox Code Playgroud)

我希望将标准从PowerShell脚本传递给函数(而不是宏).我有一切正常工作,正如预期的1条标准,但现在我想3.

我想我可以改为编写一个宏来插入一个新的工作表,写入标准然后过滤新的范围,但我宁愿先检查首选方式.

excel vba dictionary autofilter excel-vba

4
推荐指数
1
解决办法
3103
查看次数

创建一个新文件并保存到Perl中的打开目录

基本上,我正在尝试使用今天的日期创建一个新目录,然后创建一个新文件并将其保存在该文件夹中.

我可以让所有步骤单独工作,但是文件不希望保存在目录中.基本上我正在与:

mkdir($today);
opendir(DIR, $today) or die "Error in opening dir $today\n";

    open SAVEPAGE, ">>", $savepage
    or die "Unable to open $savepage for output - $!";
    print SAVEPAGE $data;
    close(SAVEPAGE);

closedir(DIR);
Run Code Online (Sandbox Code Playgroud)

我已经做了很多搜索,试图找到一个合适的例子,但不幸的是,我尝试的查询中的每一个字都获得了数百万次点击"打开/保存/文件/目录"等等.我意识到我可以更好地处理错误等,一旦我使功能正常工作,那将是下一步.任何指针都会受到赞赏,欢呼.

directory perl

0
推荐指数
1
解决办法
316
查看次数