Macauley
Macauley

Reputation: 399

Calling a Variable on the Command Line in VBA

I have a variable in my VBA script and I'm trying to call that variable on the command line within the script.

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

I am trying to call the variable strFirstLine which contains a a pathway I want the command line to read and then CD to it. Is there anyway to do this?

Thank you!

Upvotes: 0

Views: 1108

Answers (1)

Paul Ogilvie
Paul Ogilvie

Reputation: 25286

You will want to pass the value of strFirsLine, not the name. Use (example):

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

Upvotes: 1

Related Questions