Visual Basic Programmin

Posted on 2011-02-23
Medium Priority
Last Modified: 2013-11-26
I am trying to modify an existing macro. The existing macro automaticall puts in today's date. I want to add to the macro. I want it to also put in a some more text, the user's first initial and last name, thier unit code, job title and office code . For Example: 02/23/11 jtalbott Job tile: TSR Office : E14 Unit: 3311.
Here is the existing macor:
DESCRIPTION=Today's Date mmddyy


REM Created by Bill Louden, Seattle RO.  Last modified 01/03/05 at 9:01 AM PT.
REM Types the current 6-digit date at whatever point the cursor is placed.
REM ------------------------------------------------------------------------------------------------
      REM Declare the objects
      REM ECLPS is the (P)resentation (S)pace
      REM ECLSession is the Session
      REM ECLOIA is the (O)peration (I)nformation (A)rea

Dim objautECLPS
Dim objautECLSession
Dim objautECLOIA
Dim sysObj
Dim DateToday
Dim DateMonth
Dim DateDay
Dim DateYear
Dim CurPosRow
Dim CurPosCol

      REM Set and activate the objects

Set objautECLPS = CreateObject("PCOMM.autECLPS")

Set objautECLSession = CreateObject("PCOMM.autECLSession")

Set objautECLOIA = CreateObject("PCOMM.autECLOIA")

Set sysObj = CreateObject("PCOMM.autSystem")

sub subSub1_()

If objautECLPS.getText(2, 64, 6) = "TERMID" then

            REM Check to see if user is on the SSA MAIN MENU.

      MsgBox "Please Login first.",, "User Not Logged In"

      Exit Sub

ElseIf objautECLPS.getText(2, 77, 4) = "CIGN" Then

            REM Check to see if user is on the Welcome/Login screen.

      MsgBox "Please Login first.",,"User Not Logged In"

      Exit Sub

ElseIf objautECLPS.getText(1, 11, 53) = "Enter Password To Unlock; CESF Or Clearkey To Signoff" Then

            REM Check to see if user is locked out (but logged in).

      MsgBox "Mainframe is locked:  Password required." & Chr(13) & "Enter your password and try again." , ,"User Locked Out"

      Exit Sub

      CurPosRow = objautECLPS.CursorPosRow
      CurPosCol = objautECLPS.CursorPosCol
      DateMonth = Month(date)      
      DateDay = Day(date)
      DateYear = Year(date)      

      If DateMonth < 10 Then
            DateMonth = "0" & DateMonth
      End If
      If DateDay < 10 Then
            DateDay = "0" & DateDay
      End If
      DateYear = Mid(DateYear, 3, 2)

      DateToday = DateMonth & DateDay & DateYear

      objautECLPS.sendkeys DateToday

      Set objautECLPS = Nothing
      Set objautECLSession = Nothing
      Set objautECLOIA = Nothing
      Set sysObj = Nothing
      Set DateToday = Nothing
      Set DateMonth = Nothing
      Set DateDay = Nothing
      Set DateYear = Nothing
      Set CurPosRow = Nothing
      Set CurPosCol = Nothing
      Exit Sub

End If

End Sub

HERE is a macor I recorded that shows what I want added to the exisitng macro:

REM This line calls the macro subroutine

sub subSub1_()
   autECLSession.autECLPS.SendKeys "E14 jtalbott TSR Office E14 Unit 3311"
end sub
Question by:jtalbott
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 35

Expert Comment

by:Gary Patterson
ID: 34963043
Just copy and paste the lines (excluding sub/end sub) that you recorded after the Sendkeys line in the original macro, I guess.

Author Comment

ID: 34963150
I do not see a send key.
LVL 35

Expert Comment

by:Gary Patterson
ID: 34963297
Then look again. :-)

Author Comment

ID: 34963911
Gatcha. thanks
LVL 35

Accepted Solution

Gary Patterson earned 2000 total points
ID: 34963993
After this line in the original script:

  objautECLPS.sendkeys DateToday

Paste these lines from your recorded macro:

   autECLSession.autECLPS.SendKeys "E14 jtalbott TSR Office E14 Unit 3311"

And now the macro will:

Send the characters in the DateToday variable to the current screen.
Wat for the application to return to "Available" status
Wait for the emulator session to return to "Input Ready" status
Send "E14 jtalbott TSR Office E14 Unit 3311" to the current screen.

- Gary Patterson


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question