0

I am running a macro to call a screen and input a date. How do I pass a user input variable from VBA (date) into a BlueZone field?

I've tried using a shell command, but I'm getting an error... I don't think this is the right approach, though.

Sub RunReportUserDate()

Dim bzhao, WshShell As Object

Set WshShell = WScript.CreateObject("WScript.Shell")
myDate = InputBox("Enter Date", "mmddyy")

Set bzhao = CreateObject("BZWhll.WhllObj")
bzhao.Connect ""

bzhao.SendKey "<PF3>"
bzhao.WaitForString "0m" & Chr(27) & "[14;15H", 30
bzhao.SendKey "a"
bzhao.WaitForString Chr(27) & "[C", 30
bzhao.SendKey "r"
bzhao.WaitForString Chr(27) & "[C", 30
bzhao.SendKey "d"
bzhao.WaitForString Chr(27) & "[C", 30
bzhao.SendKey "a"
bzhao.WaitForString Chr(27) & "[C", 30
bzhao.SendKey "a"
bzhao.WaitForString "7H" & Chr(27) & "[16;15H", 30
bzhao.SendKey "<Enter>"
bzhao.WaitForString "er." & Chr(27) & "[6;36H", 30
bzhao.SendKey "<Tab>"
bzhao.WaitForString "er." & Chr(27) & "[6;52H", 30
bzhao.SendKey "<Tab>"
bzhao.WaitForString "rt." & Chr(27) & "[8;52H", 30
bzhao.SendKey "<Tab>"
bzhao.WaitForString "  " & Chr(27) & "[10;36H", 30
bzhao.SendKey "<Tab>"
bzhao.WaitForString "r." & Chr(27) & "[10;52H", 30
bzhao.SendKey "<Tab>"
bzhao.WaitForString "  " & Chr(27) & "[12;52H", 30


WshShell.SendKeys myDate

'bzhao.SendKey "<Numpad1>"
'bzhao.WaitForString "12;53H" & Chr(27) & "[0m", 30
'bzhao.SendKey "<Numpad0>"
'bzhao.WaitForString "[0;7m0" & Chr(27) & "[0m", 30
'bzhao.SendKey "<PF2>"
'bzhao.SendKey "<Numpad1>"
'bzhao.WaitForString "[0;7m1" & Chr(27) & "[0m", 30
'bzhao.SendKey "<Numpad9>"
'bzhao.WaitForString "[0;7m9" & Chr(27) & "[0m", 30
'bzhao.SendKey "<PF2>"
'bzhao.SendKey "<Numpad1>"
'bzhao.WaitForString "[0;7m1" & Chr(27) & "[0m", 30
'bzhao.SendKey "<Numpad9>"

The user prompt should capture a variable e.g. 101919 and input it into the date field of BlueZone.

AKdelBosque
  • 95
  • 15
  • You could dynamically create the code by looping through each of the characters in the input string then create your own 'Executer' https://stackoverflow.com/questions/43216390/how-to-run-a-string-as-a-command-in-vba – Jeremy Hodge Oct 25 '19 at 14:34

1 Answers1

0
Sub RunARDAA()

Dim bzhao As Object

myDate = InputBox("Enter Date", "mmddyy")

Set bzhao = CreateObject("BZWhll.WhllObj")
bzhao.Connect ""

bzhao.SendKey "<PF3>"
bzhao.SendKey "ARDAA"
bzhao.SendKey "<enter>"
bzhao.SendKey "<tab>"
bzhao.SendKey "<tab>"
bzhao.SendKey "<tab>"
bzhao.SendKey "<tab>"
bzhao.SendKey "<tab>"

bzhao.SendKey myDate

bzhao.SendKey "<tab>"
bzhao.SendKey " "
bzhao.SendKey "<tab>"
bzhao.SendKey " "
bzhao.SendKey "<enter>"
bzhao.SendKey "<enter>"

bzhao.SendKey "<PF3>"
bzhao.SendKey "SPRRA"
bzhao.SendKey "<enter>"
bzhao.SendKey "<enter>"


End Sub

There is no need to declare another objetc, bzhao.sendkey will recognize the stored variable from VBA.

AKdelBosque
  • 95
  • 15