문제

I have the following shell code:

RetVal = Shell("""C:\pathforprogram.exe""" + "/argument1 /argument2 /savefile=C:\textfile.txt",1)

My problem is now that i want /argument1 for example to be read from a cell. So if Cell A1 has the following string /DoThis then i would do the following:

ArgumentA = Range("A1").Value

RetVal = Shell("""C:\pathforprogram.exe""" + "ArgumentA /argument2 /savefile=C:\textfile.txt",1)

However i get the following error returned:

ArgumentA is not a valid input command

So it seems that the shell command reads ArgumentA instead of /Dothis.

Is there any solution to this? Thank you.

도움이 되었습니까?

해결책

Try this one:

ArgumentA = Range("A1").value
RetVal = Shell("""C:\pathforprogram.exe""" & ArgumentA & " /argument2 /savefile=C:\textfile.txt", 1)

also I suggest you to fully qualify your Range object:

ArgumentA = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top