[试图通过VBA shell命令将字符串名称的内容传递给Bash脚本,但它显示的是字符串名称而不是字符串的内容。
From Excel VBA
Dim Str1 As String
Dim Str2 As String
Str1 = "AAAAAAAAA"
Str2 = "BBBBBBBBB"
BASHPATH = "C:\Windows\Sysnative\bash" ' or C:\Windows\SysWOW64\bash"
WORK_DIRECTORY = "/mnt/c/Work/"
SCRIPT = "bashscript.sh Str1 Str2"
Call Shell(BASHPATH + " " + WORK_DIRECTORY + SCRIPT, 1)
来自bashcript.sh
'Run code below
echo "$1"
echo "$2"
'When you run the code above it shows:
Str1
Str2
'instead of:
AAAAAAAAAA
BBBBBBBBBB
您不替换字符串中的变量
使用此更新您的VBA脚本
SCRIPT = "bashscript.sh " & Str1 & " " & Str2