marshallgrads Absent Member.
Absent Member.
1296 views

How to find the computer name for your terminal

Legacy version of Reflection used to record Macro: 14.0
Current version of Reflection used: MICRO FOCUS REFLECTION Desktop Pro v16.0 SP-1

I am posting some of my legacy Macros that seem to work for our specific location. Not sure if others will be able to use these or gain insight on how they may tweak them to use in their settings.

1. I work on several different terminal throughout the day/week. I wanted to be able to have defaults set up depending on the terminal I was using at the time such as closest printer, closest label printer, etc... I was able to make the following macro to identify my terminal and then set some defaults that could then be used in other macros when called.

Sub COMPUTER_NAMES_LIST()
' Generated by the Reflection Macro Recorder
' NOTE: A PUBLIC VARIABLE WAS CREATED TO ALLOW IT TO BE USED IN VARIOUS MODULES. THE PUBLIC VARIABLE MAY BE SEEN IF
' YOU CLICK THE DROPDOWN BOX AND CHOOSE "DECLARATIONS" INSTEAD OF CHOOSING THE SPECIFIC SUB-name.
' WILL NEED TO CREATE PUBLIC VARIABLE FOR ANY THAT ARE NEEDED.
' BUTCH JONES 10/05/2014
'
' LISTING OF ALL THE MACROS THAT UTILIZE THIS FUNCTION
' *ADD_CULTURE_TO_UA
' *ACCESSION_ORDERS
' *REPRINT_ACCESSION_LABEL
' *REPRINT_BC_LABELS
' *VERIFY_URINALYSIS_SECTION
' *INCOMPLETE_LIST_GENERAL_DAYSHIFT
'
On Error GoTo ErrorHandler

Const NEVER_TIME_OUT = 0

Dim LF As String ' Chr(rcLF) = Chr(10) = Control-J
Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M

LF = Chr(Reflection2.ControlCodes.rcLF)
CR = Chr(Reflection2.ControlCodes.rcCR)

With Session

.CapsLock = True
.NumLock = True


'++++++++++++++++++++++++++++++++++++
'LIST OF COMPUTER NAMES THROUGHOUT THE LAB
'UPDATED ON 10/05/2014
'HEME DESK = 'LEX-WS79350'
'HEME MAIL = 'LEX-WS59930'
'DIFF DESK = 'LEX-WS78198'
'URINE DESK = 'LEX-WS74630'
'COAG DESK = 'LEX-WS59442'
'MAIN CHEM DSK = 'LEX-WS73589'
'VITROS#1 = 'LEX-WS70009'
'VITROS#2 = 'LEX-WS79294'
'MICRO PLATE = 'LEX-WS74685'
'BB SIGNOUT - 'LEX-WS66434'
'BB MAIN ST. - 'LEX-WS71365'
'BB BACKUP ST. - 'LEX-WS71371'
'BB BETHANY - 'LEX-WS71358'
'BB ANGIE ST. - 'LEX-WS71382'
'PHLEBOTOMY OUTPATIENT - 'LEX-W73525'
'+++++++++++++++++++++++++++++++++++++

'===============================================================

COMPNAME = VBA.Environ("COMPUTERNAME")

'.MsgBox "YOU ARE NOW IN COMPUTER NAME CODE >> " & COMPNAME

If COMPNAME = "LEX-WS79350" Or COMPNAME = "LEX-WS59930" Or COMPNAME = "LEX-WS78198" Then
'HEMATOLOGY
LABELPRINTER = "C93$PRT"
PAPERPRINTER = "LEX-PTLABGEN"
DEFAULTAREA = "HEME"
INCOMPLETE_DEFAULT = "HEME"
ElseIf COMPNAME = "LEX-WS74630" Then
'URINALYSIS DESK
LABELPRINTER = "C93$PRT"
PAPERPRINTER = "LEX-PTLABGEN"
DEFAULTAREA = "URINE"
INCOMPLETE_DEFAULT = "URINE"
ElseIf COMPNAME = "LEX-WS59442" Then
'COAGULATION DESK
LABELPRINTER = "C93$PRT"
PAPERPRINTER = "LEX-PTLABGEN"
DEFAULTAREA = "COAG"
INCOMPLETE_DEFAULT = "COAG"
ElseIf COMPNAME = "LEX-WS73589" Or COMPNAME = "LEX-WS70009" Or COMPNAME = "LEX-WS79294" Or COMPNAME = "LEX-WS64421" Then
'CHEMISTRY MAIN PROCESSING DESK, VITROS 1, VITROS 2
'NEW PRINTER INSTALLED 10/28/14
LABELPRINTER = "C93$PRT"
PAPERPRINTER = "LEX-PTLABGEN"
'LABELPRINTER = "CH1" - this printer removed from lab, no longer in use.
DEFAULTAREA = "CHEM"
INCOMPLETE_DEFAULT = "CHEM"
ElseIf COMPNAME = "LEX-WS66434" Then
'BLOOD BANK SIGN OUT DESK
LABELPRINTER = "BLAB1"
PAPERPRINTER = "LEX-PTBBLAB"
DEFAULTAREA = "BLOOD BANK"
INCOMPLETE_DEFAULT = "BLOOD BANK"
ElseIf COMPNAME = "LEX-WS71371" Or COMPNAME = "LEX-WS71365" Or COMPNAME = "LEX-WS71382" Then
'BLOOD BANK BACKUP STATION - STUDENT STATION
LABELPRINTER = "BLAB1"
PAPERPRINTER = "LEX-PTBBLAB"
DEFAULTAREA = "BLOOD BANK"
INCOMPLETE_DEFAULT = "BLOOD BANK"
.MsgBox "HELLO BB JONES"
ElseIf COMPNAME = "LEX-WS71358" Then
'BETHANY DESK
LABELPRINTER = "BLAB1"
PAPERPRINTER = "LEX-PTBBLAB"
DEFAULTAREA = "BLOOD BANK"
INCOMPLETE_DEFAULT = "BLOOD BANK"
ElseIf COMPNAME = "LEX-WS74685" Then
'MICROBIOLOGY PLATING DESK
LABELPRINTER = "C89$PRT"
DEFAULTAREA = "MICRO"
PAPERPRINTER = "LEX-PTMILAB"
INCOMPLETE_DEFAULT = ""
ElseIf COMPNAME = "LEX-W73525" Then
'PHLEBOTOMY DRAWING ROOM COOPER DRIVE
LABELPRINTER = "LEX-PTPHLEB1"
DEFAULTAREA = ""
INCOMPLETE_DEFAULT = ""
Else
'HEME/CHEM PRINTER
.MsgBox " DEFAULT LABEL PRINTER BEING USED, PLEASE CHECK CODE!"
LABELPRINTER = "C93$PRT"
End If
'===============================================================

.MsgBox "THE LABEL PRINTER YOU ARE PRINTING TO IS = " & LABELPRINTER

End With

Exit Sub

ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly

' Recording stopped at 07:55:41.87.
End Sub



I have used the message box feature as a tool in which to troubleshoot code and to ensure what variable I am setting and passing. You can add or comment out the message box features as you become more use to using.

I also set some PUBLIC variables by clicking the DECLARATIONS dropdown box

Public LABELPRINTER As String
Public DEFAULTAREA As String
Public PAPERPRINTER As String
Public INCOMPLETE_DEFAULT As String
0 Likes
2 Replies
AutomaticReply Absent Member.
Absent Member.

Re: How to find the computer name for your terminal

marshallgrads,

It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.

These forums are peer-to-peer, best effort, volunteer run and that if your issue
is urgent or not getting a response, you might try one of the following options:

- Visit https://www.microfocus.com/support-and-services and search the knowledgebase and/or check
all the other self support options and support programs available.
- Open a service request: https://www.microfocus.com/support
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.microfocus.com)
- You might consider hiring a local partner to assist you.
https://www.partnernetprogram.com/partnerfinder/find.html

Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.microfocus.com/faq.php

Sometimes this automatic posting will alert someone that can respond.

If this is a reply to a duplicate posting or otherwise posted in error, please
ignore and accept our apologies and rest assured we will issue a stern reprimand
to our posting bot.

Good luck!

Your Micro Focus Forums Team
http://forums.microfocus.com



0 Likes
vfast Absent Member.
Absent Member.

Re: How to find the computer name for your terminal

Great example! thanks for posting.

Some computer information and commonly needed folder names are available as standard environment variables that can be retrieved with "Environ", but if you need more extensive details, see examples from Microsoft on using WMI...it is fun just to look though this list and see everything you can do. VBScript examples are easily adapted for Reflection VBA.

WMI Tasks for Scripts and Applications
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.