Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I can't create a simple VBA macro to search and find 1

Status
Not open for further replies.

Humbled_Guy

Programmer
Mar 20, 2017
7
US
Hello and thank you for taking interest in helping me with my problem. First and foremost I am billing coder with aspirations of becoming a programmer one day. This year was the year that I discovered macros, scripts, automation, etc. and I have completely falling in love with it. However I only know what I know (and that's not allot), the problem that I am having is creating a vba macro that is embedded in a program my job use which is called "Powerterm Pro". In the past I figured out how to copy screen data via the emulation screen (vt3020-7) and paste it to excel, and from there I created other macros to basically search for billing codes, copy the cell and return the matching data back to Powerterm. However now, I would like to ditch using excel and "recreate" the macro that I was using in excel, in Powerterm Pro (which features VBA, but with it's own methods, procedures, etc.). Here is the code that I created for excel:

Code:
Option Explicit

Sub Test()

Dim RetValue As String
Dim Prompt As String
Dim Rng As Range

With Sheets("BDEscreen")

Do While True
RetValue = InputBox(Prompt:="Enter ABN Test", Title:="Optum360 TM", Xpos:=3090, YPos:=10500)

'If no test entered

If RetValue = "" Then
Call ReturnToBDE
Call SendKeyNumOff
DoEvents
Exit Do
End If

'If test is found

Set Rng = .Columns("B:B").Cells.Find(What:=RetValue, After:=.Range("B9"), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)

'If test is not found

If Rng Is Nothing Then
Prompt = "Test """ & RetValue & """ not found," & " press ESC to exit"

Range("b31").Value = RetValue
DoEvents

Else

Range("b31").Value = RetValue
Call ReturnToBDE

DoEvents

End If
Prompt = Prompt & vbLf

Loop

End With
Exit Sub

End Sub

So for the last 2 months I have been searching every website that I possibly could and unfortunately I cannot find anything to help me with recreating this within the Powerterm application. Below is the code that I tried to recreate using the powerterm methods, but I just can't do it. Please help...

Code:
Sub Testbeta()
Dim AbnTest As String
Dim Prompt As String
Dim Rng As Object

PtermPro.Application.Setup.EmulationType = ptVt320_7

Do While True
AbnTest = InputBox(Prompt:="Enter ABN Test", Title:="Optum360 TM", Xpos:=3090, YPos:=10500) [COLOR=#73D216]'this works fine[/color]

'If no test entered
    If AbnTest = "" Then
    Call ReturnToBDE
    Exit Do
    End If

'If test is found

Rng = PtermPro.Application.VBA.Trim(CStr(PtermPro.GetScreenText(1, 1, 24, 80))) [COLOR=#CC0000]'however Powerterm does not use Range, instead Col & Rows, I don't know the correct syntax[/color]

'If test is not found 

[COLOR=#EF2929]What do I do?[/color]

'If Rng Is Nothing Then
Prompt = "ABN Test Not Found """ & AbnTest & """ not found," & " press ESC to exit"

Else

[COLOR=#EF2929]What do I do?[/color]

End If
Prompt = Prompt & vbLf
Loop
Exit Sub

End Sub

I have also included some links that explain allot of PowerTerm's vba expressions, methods, etc. if you care to read

VBA Commands by Category
Programmer’s Reference
PowerTerm Pro VBA Sample Scripts
 
hi,

I am billing coder with aspirations of becoming a programmer one day.

I had a similar experience. I grew up and learned to become a programmer. I was 40ish when I really began to learn. About 55 when I discovered Excel VBA and six years later discovered Tek-Tips and things took off! You can learn a lot here.

I also learned to scrape an IBM 3270 terminal emulator (Attachmate!Extra). So I coded in Excel VBA, primarily because 1) my driver data and result data needed to be in Excel and 2) the Excel VB Editor was light years better than the Extra VB editor. It's like the difference between driving a Porsche and a Vega.

I have no idea what the Powerterm Object Model is, but you'll need to learn that. Can give you some general help VBA but not specific help.

What specifically do you need?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I would like to ditch using excel and "recreate" the macro that I was using in excel, in Powerterm Pro

So what will be the output product of your program in Powerterm?

In my world, I'd have a list of items to access via a screen/transaction on the emulator and for each item, one or more associated items to report back to a user. So I needed a spreadsheet in almost all instances.

So I had a table that described the fields on each and every screen and a bunch of supporting functions, to be able to scrape every data field on each screen and create a row in a table for that screen that contained all the data fields. Couldn't do that with just an Extra VB program nor just a powerterm program, I'd guess.

In the past I figured out how to copy screen data via the emulation screen (vt3020-7) and paste it to excel
If you were to grab each data field and put in a table rather than copy/paste a screen, a table is much simpler to analyze than a screen copy.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thank you for your awesome reply Skip! How you were at 40 is exactly how I am at 38 :) (concerning programming). Skip please have a look at this screenshot of the workflow example. Hopefully this can help you understand better exactly what it is that I'm trying to accomplish. Also if you could stair me in the right direction as far as a working syntax that will at least allow me to build from. I guess it doesn't' have to be the exact code, but somewhere near the correct language that I am trying to speak, if this was a language, I am asking you basically how to correctly write a sentence (if that makes sense).
Click here for a larger size
SC_Capture_hvi44u.png
 
Okay I see (left to right) a terminal screen that I'm guessing is a Powerterm input screen, the middle panel is a patient form, the data of which you need to enter into our mainframe patient tracking system and the right panel is Excel that you currently use.

But all that has no bearing on the language needed.

So how do you propose to get the text off the patient form and into the Powerterm screen?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I don't really need to copy/paste the data since it's already there. I guess what I'm looking for is:
1. a way to enter a numeric value (test code)
2. have it search/compare via on screen data
3. move the cursor position to the corresponding 1-15 "No. selection",
4. left button click to highlight (in which will automatically copy that number)

And from this point, I can paste the copied value accordingly and thus one test successfully entered.
 
1. a way to enter a numeric value (test code)

Do you mean a way other than typing the number from the form into the Optum360 TM box?

Where does 34429 come from?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
From the emulation screen (powerterm), simply entering a test code (IE 34429)is prohibited, instead you are expected to find the test code on the imaged requisition (2nd screen aka image viewer) and select the corresponding code by selecting the 1-15 number (only options to enter are 1-15). When there are allot of codes to match, this can become very tedious. I am trying to bypass this old method by entering the test code and automate a method to select the corresponding No. rather than manually doing it.
 
So the second image is the image viewer? So you actually SELECT text on this Powerterm screen and then what?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Correct (image viewer), the Optum box is the input boxe I created and intend to pass the numeric vals (tests) to the emu screen. So after the test is selected, the next ordered test is selected (1<enter>, 4<enter>,etc)and then the req is processed and powerterm pulls the next req to be processed.
 
So the user must select each test from the image viewer and then issue a requisition.

So how is a coded solution supposed to work?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Are ALL the tests available for EVERYONE contained on ONE screen of 15 items?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
The test are scraped via the initial data input via the lab, after the laboratory work is processed (blood work, urine samples, imaging of reqs, etc) then once the information is imaged, our billing department pulls from various ques to be coded and eventually billed. So each req will populate tests that are ordered from the client, at the billing stage, the purpose of reentering the tests are for verification and confirmation purposes.
 
I'm trying to figure out the process.

You have 15 tests on one screen. Is that just for this patient?



Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Yes you are correct, each requisition is a representation of one patient. If the doctor ordered 3 test to be performed for the patient then 3 test will be ordered (Hospital etc), performed (via the lab) and billed (via my department, the billing dept).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top