从excel shell命令将多个变量的内容传递到bash脚本中

问题描述 投票:0回答:1

[试图通过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
excel bash
1个回答
0
投票

您不替换字符串中的变量

使用此更新您的VBA脚本

SCRIPT = "bashscript.sh " & Str1 & " " & Str2
© www.soinside.com 2019 - 2024. All rights reserved.