无法执行剪切粘贴 VBScript
我一直在疯狂地试图找出为什么我的脚本不起作用,直到我开始直接从一些网站复制和粘贴示例源代码,结果它也在那里失败。我的 VBScript 中出现以下错误:
C:\temp\vbs\script.vbs(19, 53) Microsoft VBScript 编译错误:预期语句'
对于如下所示的一行代码:
wdoc.Application.Selection.Find.Execute Replace:=wdReplaceAll
这是与 Office 2007 中的 Microsft Word 交互以进行搜索和替换。索引 53 直接指向赋值的 := 部分。由于这种类型的语法在我的机器上不起作用,并且我在多个网站上使用它,所以我想知道我使用的 cscript.exe 是否已过时。
我没有正确调用 cscript 吗?
I have been going mad trying to figure out why my scripts weren't working, until I started copying and pasting sample source code directly from a few websites only to have it fail there as well. I am getting the following error in my VBScripts:
C:\temp\vbs\script.vbs(19, 53) Microsoft VBScript compilation error: Expected statement'
For a line of code that looks like this:
wdoc.Application.Selection.Find.Execute Replace:=wdReplaceAll
This is interfacing with Microsft Word in Office 2007 to conduct a search and replace. Index 53 point directly to the := part of the assignment. Since this type of syntax doesn't work on my machine and I am using it from several websites, I was wondering if the cscript.exe I use is out of date.
Am I not calling cscript properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
命名参数 (
Param:=Value
) 是 Visual Basic 和 VBA 功能; VBScript 不支持此语法。在 VBScript 中,您需要保留例程参数的实际顺序。如果特定参数是可选的并且您想使用其默认值,则只需省略该参数即可。所以,你的代码应该是这样的:
Named arguments (
Param:=Value
) are Visual Basic and VBA feature; this syntax isn't supported in VBScript.In VBScript, you need to preserve the actual order of a routine's arguments. If a specific argument is optional and you want to use its default value, you need to simply omit that argument. So, your code should look like this: