【发布时间】:2017-12-04 11:17:28
【问题描述】:
我需要更改多个文本文件中的字符串
我在 ACCESS VBA 中编写了下面的脚本,但错误是 TYPE MISMATCH
Dim str As String
str = "N=maher"
Call Shell("c:\windows\system32\powershell.exe" - Command("get-content -Path e:\temptest.txt") - Replace(str, "maher", "ali"))
【问题讨论】:
-
这应该可以工作:
-Command ("get-content -Path e:\temptest.txt").Replace("maher", "ali") -
我不这么认为。如果我不得不猜测,
-replace旨在在 PowerShell 环境中验证,而不是在 VBA 环境中验证。但是OP没有告诉我们,所以没人知道。 -
显然是 x-y 问题。如果要使用 VBA 替换文件中的字符串,则无需涉及 PowerShell。
标签: vba powershell ms-access