# Excel VBA and IBM Emulator ActiveX Error



## MCTampa (Jan 31, 2019)

Hello,

I am trying to use a macro that was designed by a former colleague.  
It is a rather standard macro to automate data input into an IBM Emulator.

Below is the script (the creator was French):
The error is occurring at the MySession.SetConnectionByName (SessionName) line.
The macro references Cell coordinates 4,3 in which I have an A.

The message I receive is "Run-time error '429':  ActiveX component can't create object.
However after a good deal of searching around, I cannot figure out what the issue is.


```
Private Sub BtnSEND_Click()

Dim i, j As Integer
Dim MySession As New AutSess
Dim OIA As New AutOIA
Dim PS As New AutPS
Dim DerLigne, Ligne1 As Integer
Dim DerCol, Col1 As Integer
Dim SessionName As String
Dim NbCaract As Integer
Const NumLigneAction = 7 'Numéro de la ligne Action
Const NumLigneRow = 8 'Numéro de la ligne Row
Const NumLigneCol = 9 'Numéro de la ligne Col
'Récupération du périmétre à traiter
Ligne1 = Cells(2, 3).Value
Col1 = Cells(2, 6).Value
DerLigne = Cells(3, 3).Value
DerCol = Cells(3, 6).Value
'Récupération du nom de la session
SessionName = CStr(Cells(4, 3).Value)

'Connection à la session de la NA
MySession.SetConnectionByName (SessionName)
Set OIA = MySession.autECLOIA
Set PS = MySession.autECLPS

'Boucle sur le nb de ligne
For i = Ligne1 To DerLigne
    OIA.WaitForAppAvailable
    OIA.WaitForInputReady
    'Boucle sur les colonnes
    For j = Col1 To DerCol
        Select Case UCase(Cells(NumLigneAction, j).Value)
        'pour inscrire la donnée dans la NA
        Case "PUT"
            If Cells(i, j).Value <> "" Then
                PS.SendKeys Cells(i, j).Value, Cells(NumLigneRow, j).Value, Cells(NumLigneCol, j).Value
                OIA.WaitForInputReady
            End If
        'Pour lancer une commande NA, par exemple ENTER ou PF2
        Case "COM"
            If Cells(i, j).Value <> "" Then
                PS.SendKeys ("[" & UCase(CStr(Cells(i, j).Value)) & "]")
                OIA.WaitForInputReady
                PS.WaitForAttrib 1, 2, "00", "3c", 3, 2000
                PS.WaitForCursor 1, 3, 2000
            End If
        'Mettre une zone à blanc
        Case "BLANK"
            If Cells(i, j).Value <> "" Then
                PS.SendKeys String(Cells(i, j).Value, " "), Cells(NumLigneRow, j).Value, Cells(NumLigneCol, j).Value
                OIA.WaitForInputReady
            End If
        'Pour récupérer une donnée sur la NA dans le fichier Excel
        Case Else
            NbCaract = CInt(Mid$(Cells(NumLigneAction, j).Value, 4, 2))
            Cells(i, j).Value = PS.GetText(Cells(NumLigneRow, j).Value, Cells(NumLigneCol, j).Value, NbCaract)
        End Select
    Next j
Next i
PS.WaitForAttrib 1, 2, "00", "3c", 3, 2000
PS.WaitForCursor 1, 3, 2000
Set OIA = Nothing
Set PS = Nothing
End Sub
```


----------



## MCTampa (Jan 31, 2019)

As a follow up, I have the following References checked in VBA Project (in the below order):
Visual Basic for Applications
Microsoft Excel 15.0 Object Library
OLE Automation
Microsoft Office 15.0 Object Library
Microsoft Form 2.0 Object Library
PCOMM autECLOIA Automation Object 1.0 Library
PCOMM autECLPS Automation Object 1.0 Library
PCOMM autECLSession Automation Object 1.0 Library
Microsoft ActiveX Data Objects (Multi-dimensional) 6.0 Library
Microsoft ActiveX Data Objects Recordset 6.0 Library
PCOMM Emulator Settings Automation Objects 1.0 Library

Am I missing anything?  Should I be using an older version of anything?


----------



## B___P (Feb 1, 2019)

Hi MCTampa,
this is the piece of code I use to dim objects and to set them. I think it will be easy for you to customize it.


```
Dim eclps As Object, ecloia As Object
Set eclps = CreateObject("PCOMM.autECLPS")
Set ecloia = CreateObject("Pcomm.autecloia")
eclps.SetConnectionByName ("A")
ecloia.SetConnectionByName ("A")
```

Hope this helps and have a nice weekend.


----------



## shg (Feb 1, 2019)

Are you using 64-bit Excel? If so, see http://www-01.ibm.com/support/docview.wss?uid=swg1IC99468


----------



## MCTampa (Feb 1, 2019)

shg said:


> Are you using 64-bit Excel? If so, see http://www-01.ibm.com/support/docview.wss?uid=swg1IC99468



That was the issue.  Figured it out late last night and got the IT guys to drop off a 32-bit Office.
Works now.

Thanks
Mike


----------



## shg (Feb 1, 2019)

Welcome.


----------

