MCTampa
Board Regular
- Joined
- Apr 14, 2016
- Messages
- 97
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.
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.
Code:
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
Last edited by a moderator: