On the Excel command line I want to be able to pass a random string, and I want to be able to read that string in VBA. For example:
Right now in my CommandLine.xlsm I have a simple function which I wrote only to make it visible to the UI -- it's supposed to read the command line using the built-in function Command$ (in VBA.Interaction):
I've see all those Windows-API functions that read the command line, but even if I use all those the problem is that 1) Excel thinks "here's my random string" is the name of a file, which it tries to open and obviously can't find, so I get an error, and 2) Command$ always returns a null string even if I pass various known-good switches like /e or /m.
So what I want is a way to get that random string from the Windows command line into a VBA string variable without Excel processing it in any way. In other words, I want to be able to issue the above Excel command line (or some variation) and for Excel to open CommandLine.xlsm with no error messages and for its CommandLine function to return "here's my random string". How can I simply pass any string on the command line that I can read into a string in VBA?
"C:\Program Files (x86)\Microsoft Office\root\Office16\excel.exe" CommandLine.xlsm "here's my random string"
Right now in my CommandLine.xlsm I have a simple function which I wrote only to make it visible to the UI -- it's supposed to read the command line using the built-in function Command$ (in VBA.Interaction):
VBA Code:
Public Function CommandLine() As String
CommandLine = Command$()
End Function
So what I want is a way to get that random string from the Windows command line into a VBA string variable without Excel processing it in any way. In other words, I want to be able to issue the above Excel command line (or some variation) and for Excel to open CommandLine.xlsm with no error messages and for its CommandLine function to return "here's my random string". How can I simply pass any string on the command line that I can read into a string in VBA?