Rocket Terminal Emulator

 View Only

 Issue with VBA macros in 7.x versions of BlueZone -- works in 5.x

Sean Strickland's profile image
Sean Strickland posted 02-03-2021 14:00
We have some macros triggering from Microsoft Office products via VBA that connect to BlueZone to run small-scale automation.  In recent months, we've noticed some issues with users being unable to trigger these macros on their 7.x installations, but others that have 5.x (e.g. BlueZone Mainframe Display v5.2 Build 1418) are still able to run correctly.  Are there changes needed to VBA macros to function appropriately with 7.x installations?

Function examples that are working in 5, but not 7:
'Define global Bluezone Variables
Global SystemBZ As Object
Global Sess0
Global Screen

Global Const TestEnvironment As Boolean = False
Global Const DEFAULT_SCREEN As String = "LACO0010"

'###############################################
'# Name: BZ_Connect()
'# PURPOSE: Create a new Bluezone Connection
'###############################################
Sub BZ_Connect()
Set SystemBZ = CreateObject("BZWhll.Whllobj")
Set Sess0 = SystemBZ.ActiveSession
Set Screen = Sess0.Screen
End Sub

'###################################################
'# Name: BZ_Terminate()
'# PURPOSE: Terminate Existing Bluezone Connection
'###################################################
Sub BZ_Terminate()
If Not (SystemBZ Is Nothing) Then
    SystemBZ.Disconnect
    Set SystemBZ = Nothing
    Set Sess0 = Nothing
    Set Screen = Nothing
End If
End Sub

'###############################################
'# Name: BZ_Initiate()
'# PURPOSE: Initiate a new Bluezone Connection
'###############################################
Function BZ_Initiate()
'Terminate the existing session
Call BZ_Terminate

'Create a new connection to BlueZone
Call BZ_Connect
End Function

'###############################################
'# Name: ReadScreen()
'# PURPOSE: Bluezone Screen Scrape
'# Returns: String
'###############################################
Function ReadScreen(L As Integer, x As Integer, y As Integer, Optional blnTrim As Boolean = False)
SystemBZ.ReadScreen ReadScreen, L, x, y
If blnTrim Then
    ReadScreen = Trim(ReadScreen)
End If
End Function

'###############################################
'# Name: WriteScreen()
'# PURPOSE: Write data to Bluezone
'###############################################
Sub WriteScreen(str, x As Integer, y As Integer)
SystemBZ.WriteScreen str, x, y
End Sub

'###############################################
'# Name: Send()
'# PURPOSE: Send keys to Bluezone
'###############################################
Sub Send(str As String, lWait As Long)
Screen.SendKeys str

Select Case str
Case "<ENTER>", "<PF1>", "<PF2>", "<PF3>", "<PF4>", "<PF5>", "<PF6>", "<PF7>", "<PF8>", "<PF9>", "<PF10>", "<PF11>", _
     "<PF12>", "<PF13>", "<PF14>", "<PF15>", "<PF16>", "<PF17>", "<PF18>", "<PF19>", "<PF20>", "<PF21>", "<PF22>", _
     "<PF23>", "<PF24>", "<PA1>"
     
    SystemBZ.WaitReady 10, lWait
End Select
End Sub

'###############################################
'# Name: SetCursor()
'# PURPOSE: Send keys to Bluezone
'###############################################
Sub SetCursor(x As Integer, y As Integer)
SystemBZ.SetCursor x, y
End Sub
​
Mike Slater's profile image
ROCKETEER Mike Slater
Hi Sean,

Your macro is "mixing" BlueZone and 3rd-party compatibility APIs in BlueZone. This is Ok, but we significantly enhanced the compatibility APIs in BlueZone v6+. As a result, it is now required to enable the "Allow Multiple Simultaneous Connections" checkbox in the Options-API dialog. Please see if enabling this checkbox resolves the issue?

Thanks,
Mike
Sean Strickland's profile image
Sean Strickland
Thanks @Mike Slater - we gave it a shot, updated the setting and we still get this "permission denied" error.  Any other ideas for us to try out?

Error occurs on this line:
Set SystemBZ = CreateObject("BZWhll.Whllobj")
​
Attachment  View in library
Michael Hlusak's profile image
Michael Hlusak
Have you checked the references in VBA? The machines with BZ 5 I would think need to use different references ​
So ideally you would have 2 different excel xlxs files. 1 fo r BZ 7 users and another for BZ 5 users

I am no expert, just my guess


These s/b changed to BZ5xxx Type Library for the machines with BZ 5 on them I think
Mike Slater's profile image
ROCKETEER Mike Slater
For this "permission denied" error, it's likely security related, can you check if the user has Read Execute permissions on file Bzwhll.dll in the Program Files BlueZone\7.1 folder? You mentioned "In Recent Months,...", so maybe your IT made a change to Group Policy for some users' ability to invoke COM objects? It may also be related to settings in a Antivirus software that was recently installed or configured, I was reading online.
Sean Strickland's profile image
Sean Strickland
Thanks @Michael Hlusak - the only reference I actually see (have ever seen) is BZWhll 1.0 Type Library and that's checked.  Appreciate the thought - definitely worth checking into!  I've certainly seen cases in the past where changing a reference made all the difference.

@Mike Slater​​ - that's a good thought and very possible.  I'll circle back after we check that.  

On the reference libraries -- is it normal to have the 1.0 library currently or should we have a more recent version?
Mike Slater's profile image
ROCKETEER Mike Slater
You should see a different item for BZWhll Type Library in the Tools-References dialog for v7.1. Note in BlueZone v7.1+ it includes both 32-bit and 64-bit builds, in the win32 and x64 folders on CD image. You need to install the bitness of BlueZone that matches the bitness of MS Office installed, in this case the 32-bit build, did you maybe install the 64-bit build of BlueZone? If not, you can try to re-register the v7.1 objects by running a DOS prompt As Administrator and running the commands:

First un-register the objects:
Regsvr32 "C:\Program Files (x86)\BlueZone\7.1\Bzwhll.dll" /u

Then re-register the objects:
Regsvr32 "C:\Program Files (x86)\BlueZone\7.1\Bzwhll.dll"

Alternatively, you can un-install and re-install BlueZone v7.1 to re-register the objects. Another tip when upgrading BlueZone from v5-, you need to first un-install v5 before installing v7, because the v5 un-install doesn't know about the enhanced multiple side-by-side versions of BlueZone feature, so will inadvertently un-register the v7.1 global object Prog IDs. If this happens you will need to re-register the v7.1 objects.

Also, when declaring the base variable As Object, and invoking the objects with the CreateObject() method, it is not necessary to enable/check the BZWhll Type Library checkbox in the Tools-References dialog, so I would recommend to disable the checkbox. This way your macros project will not be "tied" to a specific version of BlueZone, the CreateObject() method will always invoke the "latest installed version" of the BlueZone objects.

Thanks Sean, please let us know if this helps.