User1493
User1493

Reputation: 491

passing variables as arguments from excel VBA

I use the following code for passing arguments to my script from VBA.

Successful case: (argument value without space)

FilePath = "c:\Users\dimension_export.exe"
AppName = "Area_Sales"
Call Shell(FilePath & " " & AppName, 1)

Error case: (argument value with space (''))

FilePath = "c:\Users\dimension_export.exe"
AppName = "Total Sales"
Call Shell(FilePath & " " & AppName, 1)

when I do this, only the Total part in the AppName variable is passed as a argument to my exe file.

Is there any specific keyword or symbols I should pad up?

Upvotes: 0

Views: 47

Answers (1)

Tim Williams
Tim Williams

Reputation: 166196

Call Shell(FilePath & " " & AppName, 1)

should be

Call Shell(FilePath & " """ & AppName &  """", 1)

Any items with spaces (including the file path) should be enclosed in quotes

Upvotes: 1

Related Questions