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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Attachmate properties through Excel VBA

Status
Not open for further replies.

mattm89

Technical User
Aug 27, 2013
6
US
Hi. Based on this thread: I am trying to set the following properties to TRUE in Attachmate through Excel VBA.

Beginning in Reflection 2011 R3 SP1, while a Reflection VBA macro is running, the productivity features and Screen History are turned off automatically to improve performance. If you want to enable these features while automation is running insert the appropriate lines in the macro:

.DisableKeystrokeProductivity=FALSE
.DisableScreenHistory=FALSE

Note: If you are using a programming tool other than Reflection VBA macros, such as Microsoft Visual Studio, VBA in Microsoft Office products, etc., set these properties to True (as described in the next section) to avoid possible performance costs introduced by these features.

I am using VBA in Excel, so I want to send the following commands to Attachmate:

.DisableKeystrokeProductivity=TRUE
.DisableScreenHistory=TRUE

The start of my code looks like this currently. If someone could please show me how I would set the above properties, I would appreciate it.

Code:
Dim myscreen As Object

Function Wait()
    Do Until myscreen.OIA.XStatus <> 5
    Loop
End Function

Function System()
'Assumes an open extra session

    Set Sys = CreateObject("EXTRA.System")
    Set Sess = Sys.Sessions.Item(1)
    Sess.Activate
    Set myscreen = Sess.Screen
End Function

Note: Users are using both Extra 6.7 and Reflection 2011 R2, so this is designed to be compatible with both.

Thanks in advance for the help.
 
The answer is in the article:
For example:

ThisIbmTerminal.DisableKeystrokeProductivity = True



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Code:
Dim myscreen As Object

Function Wait()
    Do Until myscreen.OIA.XStatus <> 5
    Loop
End Function

Function System()
'Assumes an open extra session

    Set Sys = CreateObject("EXTRA.System")
    Set Sess = Sys.Sessions.Item(1)
    Sess.Activate
    Set myscreen = Sess.Screen
    ThisIbmTerminal.DisableKeystrokeProductivity = True
End Function

Adding that line results in runtime error 424 saying Object Required.
 
ThisIbmTerminal is an EXAMPLE! Use YOUR IBM terminal.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Unfortunately, this may creep beyond my level of knowledge.

From examples I have seen, I have also tried the below since myscreen has been defined in the code already:
Code:
myscreen.DisableKeystrokeProductivity = True

This returns the error "Object doesn't support this property or method".

Further investigation led me to this FAQ:
For even more functionality, add a reference (VBA - Tools>References; VB - Project>References) to Attachmate Object Library, then use this code:
<code></code>
Now you can refer to the "MyScn" object and you'll have a drop down box of all the available properties and methods.

I'm not sure if I have the correct library available, or if that is necessary. I have the below in my VBA References:
Attachmate_Reflection_Objects
Attachmate_Reflection_Objects_Framework
Attachmate_Reflection_Objects_Emulation_IbmHosts
Attachmate_Reflection_Objects_Emulation_OpenSystems

Following that approach results in an error saying all macros in my workbook are disabled. Additionally, I never get a list of properties or methods from the myscreen object.

Thanks for your quick responses.
 
Oh yes! you ought to have a reference set for Attachmate. I'd select all of them.

I'd also check Attachmate VB Help for the OBJECT reference for this property. I assumed from the link you posted, that it referred to the screen (terminal) object.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I have selected all of them. However, the ExtraScreen object in the FAQ mentioned does not seem to exist in Reflections' library. If I load the EXTRA 6.5 library, the ExtraScreen object exists, but the DisableKeystrokeProductivity property is not available for it (as expected since it will just introduced).

I noticed on these forums that the screen object for Reflections appears to be "Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen". When I am able to test on the PC with Reflections, I will try the below out and see if the library supports the property mentioned for the object.

Code:
Public myscreen As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen
....
myscreen.DisableKeystrokeProductivity

Assuming that works, I still have some possible roadblocks:
1. Our users have both Extra and Reflections. It appears this is going to break it for Extra users. Is there a way around that which would allow compatibility for both?
2. No one is going to have the libraries loaded in Excel by default. Users of Extra will not have the Reflections object library available. Both sets of users will need to be run and edit the macro from time to time (until Extra is phased out). Having to load in an additional library introduces complexity. Is there anyway to accomplish the above property setting without dealing with non-default libraries?

I will report back if the above code works.
 
You can run without the libraries, as long as you do not use library constants, for one. I don't usually configure that way, but the objects can be created and referenced without the libraries.

If you have an object for Reflection then you can check for the existence of an instance by something like this
Code:
If Not oReflection Is Nothing Then
   MsgBox "An instance exists"
Else
   MsgBox "No instance exists"
End if


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I have not been able to get the property set as I described above. It seems all of the old way of starting off the code with Extra objects, etc. are incompatible once you start mixing in things from the Reflections library, often resulting in "mismatch" errors. So I'm guessing everything else has to change.

It looks like this is what Reflections has available to use:
Attachmate_Reflection_Objects_Framework.ApplicationObject
Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen
Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal

Could someone please help re-work my initial Extra code to work with the new format so I can set this property to the screen. I can't use the old Extra objects or else I get hit with "property doesn't exist" errors. It doesn't seem like a simple find-replace activity, and I have not had success after lengthy experimentation and attempts.

If I am going in the wrong direction, please let me know. Again, the only goal of all of this is to simply set DisableKeystrokeProductivity and DisableScreenHistory to True from Excel, in order to fix the Reflection slowness caused by these features, experienced when rapidly scraping many screens. I have users with macros that take nearly 20x longer running on Reflection compared to Extra.

Thanks.
 
Note: I have achieved what I wanted in a different way. Instead of setting the property through Excel VBA, I made a small Reflection Macro that I run in Reflections before running my usual screen scrapers out of Excel.

Code:
Sub SpeedUp()

Dim ibmCurrentTerminal As IbmTerminal
Dim ibmCurrentScreen As IbmScreen
Dim returnValue As Integer

Set ibmCurrentTerminal = ThisFrame.SelectedView.Control
Set ibmCurrentScreen = ibmCurrentTerminal.Screen
'---------------------------------------------------------------------

ibmCurrentTerminal.Productivity.ScreenHistory.ClearAllScreens
ibmCurrentTerminal.Productivity.RecentTyping.ClearAllItems

ibmCurrentTerminal.DisableKeystrokeProductivity = True
ibmCurrentTerminal.DisableScreenHistory = True

returnValue = ibmCurrentScreen.WaitForText1(900000, "xxx", 4, 9, TextComparisonOption_IgnoreCase)

End Sub

This makes Reflection much faster for 15 minutes. I also created a button in the UI designer so I can disable the Screen History and Keystroke Productivity features before running any big macros.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top