在VBA中调用命令行上的变量

时间:2015-06-23 19:24:26

标签: vba outlook-vba

我的VBA脚本中有一个变量,我试图在脚本中的命令行上调用该变量。

Sub Test()
'Set enviro to %APPDATA%
Dim enviro As String
enviro = CStr(Environ("APPDATA"))
'Create a new variable that sets the file path for the RepoDir.txt
RepoPath = enviro & "\RepoDir.txt"

'Create a new variable to grab the line of text in RepoDir.txt
Dim FilePath As String
Dim strFirstLine As String

'The new variable calls the RepoPath Variable
FilePath = RepoPath
Open FilePath For Input As #1
Line Input #1, strFirstLine
'MsgBox (strFirstLine)

Shell ("cmd /c cd call strFirstLine & git pull RandomSig > %TEMP%\gitPull.txt 2>&1")

End Sub

我试图调用变量strFirstLine,其中包含一个我希望命令行读取然后CD到它的路径。反正有吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您需要传递strFirsLine的,而不是名称。使用(示例):

Shell ("cmd /c cd " & strFirstLine & "git ..."