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

Call PComm (host) from Excel. Cant exit correctly

Status
Not open for further replies.

MrStar

Programmer
Sep 30, 2002
53
DK
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
 
looks like unless findobject_a = nothing, your ExitProcedure is not called - therefore your objects are not properly closed off

You need this:

2500 Set autCon = Nothing
2510 Set Find_Object_A = Nothing
2520 Set autECLPSObj = Nothing
2530 Set autECLOIAObj = Nothing

to happen whether findobject_a is there or not....

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top