Im trying to write some VBA code in Excel. It shall use an existing connection to host through IBM Personal Communication.
I can get access to host, and I can send commands to host session. but when I close Excel, the program pcsvc.exe starts using 100% cpu.
I cant figure out what the problem is. I guess it is something about PComm still thinks it have a connection to Excel but ...
Can anybody help or provide med with the correct code for connecting to host.
I want to use an existing opne session, and I dont want to close this session after Excel is closed. The session shall remain open as it was before I start the VBA code.
My code is :
Sub testPcomm()
On Error GoTo Errorhandler
1000 Const IntHostWaitMs As Integer = 1000
1010 Dim ResultStr As String, i As Integer
1020 Dim autECLPSObj As Object
1030 Dim autCon As Object
1040 Dim autECLOIAObj As Object
1050 Dim Find_Object_A
1100 Set autCon = CreateObject("PCOMM.autECLConnMgr")
1110 autCon.autECLConnList.Refresh
1120 Set Find_Object_A = autCon.autECLConnList.findconnectionbyname("A")
1200 If Find_Object_A Is Nothing Then
1210 MsgBox "No access to Host. Is 'Session A' started ?"
1220 GoTo ExitProcedure
1230 End If
1300 Set autECLPSObj = CreateObject("PCOMM.autECLPS")
1310 Set autECLOIAObj = CreateObject("PCOMM.autECLOIA")
1320 autECLOIAObj.SetConnectionByName ("A")
' Initialize the connection
1350 autECLPSObj.SetConnectionByHandle (autCon(1).Handle)
'Just some commands to host session
1400 autECLPSObj.SendKeys "[pf24]"
1420 autECLOIAObj.WaitForInputReady IntHostWaitMs
1450 ResultStr = autECLPSObj.GetText(8, 18, 20)
ExitProcedure:
' Release attachmate objects
'On Error Resume Next
2500 Set autCon = Nothing
2510 Set Find_Object_A = Nothing
2520 Set autECLPSObj = Nothing
2530 Set autECLOIAObj = Nothing
Exit Sub
Errorhandler:
2900 MsgBox "error occured." & _
vbCrLf & "ErrorNo: " & Err & _
vbCrLf & "LineNo: " & Err.Line & _
vbCrLf & "Errormsg:" & _
vbCrLf & Err.Description, vbCritical, "Error"
3000 Resume ExitProcedure
End Sub
I can get access to host, and I can send commands to host session. but when I close Excel, the program pcsvc.exe starts using 100% cpu.
I cant figure out what the problem is. I guess it is something about PComm still thinks it have a connection to Excel but ...
Can anybody help or provide med with the correct code for connecting to host.
I want to use an existing opne session, and I dont want to close this session after Excel is closed. The session shall remain open as it was before I start the VBA code.
My code is :
Sub testPcomm()
On Error GoTo Errorhandler
1000 Const IntHostWaitMs As Integer = 1000
1010 Dim ResultStr As String, i As Integer
1020 Dim autECLPSObj As Object
1030 Dim autCon As Object
1040 Dim autECLOIAObj As Object
1050 Dim Find_Object_A
1100 Set autCon = CreateObject("PCOMM.autECLConnMgr")
1110 autCon.autECLConnList.Refresh
1120 Set Find_Object_A = autCon.autECLConnList.findconnectionbyname("A")
1200 If Find_Object_A Is Nothing Then
1210 MsgBox "No access to Host. Is 'Session A' started ?"
1220 GoTo ExitProcedure
1230 End If
1300 Set autECLPSObj = CreateObject("PCOMM.autECLPS")
1310 Set autECLOIAObj = CreateObject("PCOMM.autECLOIA")
1320 autECLOIAObj.SetConnectionByName ("A")
' Initialize the connection
1350 autECLPSObj.SetConnectionByHandle (autCon(1).Handle)
'Just some commands to host session
1400 autECLPSObj.SendKeys "[pf24]"
1420 autECLOIAObj.WaitForInputReady IntHostWaitMs
1450 ResultStr = autECLPSObj.GetText(8, 18, 20)
ExitProcedure:
' Release attachmate objects
'On Error Resume Next
2500 Set autCon = Nothing
2510 Set Find_Object_A = Nothing
2520 Set autECLPSObj = Nothing
2530 Set autECLOIAObj = Nothing
Exit Sub
Errorhandler:
2900 MsgBox "error occured." & _
vbCrLf & "ErrorNo: " & Err & _
vbCrLf & "LineNo: " & Err.Line & _
vbCrLf & "Errormsg:" & _
vbCrLf & Err.Description, vbCritical, "Error"
3000 Resume ExitProcedure
End Sub