So I currently am working on a macro that detects when an email is received in outlook, gets the sending information and copies the email content. From here I have an excel spreadsheet setup to check the user against, if it finds the user listed I have a sendkeys script to log a job in our helpdesk system.
The issue I am having is passing multiple variables to my sendkeys script.
Here is how I am passing it over from the excel macro:
strParam1 = AssystID
strParam2 = Sheets("Ext Database").Range("G3").Value
strVBSPath = "C:\Scripts\testsofar.vbs"
Shell ("wscript.exe " & strVBSPath & " " & strParam1 & strParam2)
strParam1
is a username (e.g KIERANL) from the database and strParam2
is the Item type (e.g Internal) I am logging it against.
The problem I am having is getting the correct output from the SendKeys script. Currently I am using the line: WshShell.SendKeys Wscript.Arguments(0)
which I believe should send over strParam1
, however when I am passing across multiple values it is combining them such as the examples above it would send: KIERANLINTERNAL
all on one line.
My question is what exactly am I doing incorrectly? I have looked at this page: https://technet.microsoft.com/en-us/library/ee692833.aspx and I cannot see exactly what is wrong with my method.
I think from what you have described the problem is the lack of separation between the arguments you are passing.
At the moment your command looks like this when passed
wscript.exe C:\Scripts\testsofar.vbs KIERANLINTERNAL
The problem being the two parameters have merged into one when actually you want this
wscript.exe C:\Scripts\testsofar.vbs KIERANL, INTERNAL
To do this in the code just concatenate a comma between your two arguments like this
Shell ("wscript.exe " & strVBSPath & " " & strParam1 & ", " & strParam2)