Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is a long shot, but I am hoping that somebody may be able to help.

    Code:
    Dim pcommConnMgr As AutConnMgr   'Personal Comm - Connection Manger
    Dim pcommPS As AutPS			 'Personal Communications - Presentation Space (5250 screen matrix)
    Dim pcommOIA As AutOIA		   'Personal Communications - Operator Info Area (error reset, system available, etc.)
    Dim pcommWin As AutWinMetrics	'Personal Communications - Window Characteristics (attributes of window - maximized, title, etc.)
    
    Dim intSessCount As Integer	 'Number of open sessions
    Dim intLoop As Integer
    Dim lngSessionHandle As Long	'Handle to 5250 Window
    Dim booProcessed As Boolean	 'Flag marking successful process
    	
    	Set pcommPS = New AutPS
    	Set pcommOIA = New AutOIA
    	Set pcommWin = New AutWinMetrics
    	Set pcommConnMgr = New AutConnMgr
    	
    	intSessCount = pcommConnMgr.autECLConnList.Count
    	
    For intLoop = 1 To intSessCount
    I am having problems with:

    intSessCount = pcommConnMgr.autECLConnList.Count

    I am using excel vba to input data to an external app, and the above line of code is used to identify if the external app has an active session.

    If I start a brand new excel session, without starting the app, then intSessCount = 0

    If I start the app, rerun the code, then intSessCount = 1

    But, if I close the app completely, or it times out, then intSessCount = 1 still.

    I have tried adding intSessCount = 0 prior to the count, but this still does not work. It seems that this is only reset when I completely quit excel.

    Any idea's how I can get this back to zero?

    TIA.

  2. #2
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also:

    If I open the workbook and the external app is closed, then the count is 0. If I close the workbook, open the external app, and reopen the workbook (in the same session of excel, without quitting), the count is still 0. This makes no sense to me

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You'll need somebody who has detailed knowledge about the external application for this; I don't think we can answer your questions with general Excel and VBA knowledge.

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='VegasNath' post='788239' date='10-Aug-2009 07:40']Also:

    If I open the workbook and the external app is closed, then the count is 0. If I close the workbook, open the external app, and reopen the workbook (in the same session of excel, without quitting), the count is still 0. This makes no sense to me [/quote]

    Does the following approach help? It tests to see if a third party app (NoteTab) is running, and launches it if not. Take note that if NoteTab is not running but another application named NoteTabxyz is, NoteTabxyz will be activated and no error will be detected at line 30.
    Code:
       Public Sub Check4RunningApp()
       10		On Error Resume Next
       20		AppActivate "NoteTab"
       30		If Err Then
       40			On Error GoTo 0
       50			returnvalue = _
    					 Shell("L:\Laptop Secondary Copy\Program Files\NoteTab Light\NoteTab.exe", _
    					 vbNormalFocus)
       60		End If
    			 
       End Sub
    Regards
    Don

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='VegasNath' post='788238' date='10-Aug-2009 03:57']I have tried adding intSessCount = 0 prior to the count, but this still does not work. It seems that this is only reset when I completely quit excel.[/quote]
    Is there a method to disconnect from and end the session with the external COM object? If not, it may be maintaining a session with Excel even after your procedure ends.

  6. #6
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks for all of your input.

    [quote name='jscher2000' post='788321' date='10-Aug-2009 21:08']Is there a method to disconnect from and end the session with the external COM object? If not, it may be maintaining a session with Excel even after your procedure ends.[/quote]

    In a nutshell, I think that is the problem. I've been frantically searching the net trying to get to the bottom of this, I don't give up easily

    I need to have control of the session count at all times, so not to be processing data with a session count of 0.

    It would seem that I need to refresh the count each time I assess the value so I hope that this works.

    Code:
    pcommConnMgr.autECLConnList.Refresh
    intSessCount = pcommConnMgr.autECLConnList.Count
    Source of info: ibm

    My next step is to ascertain if an emulator window is open, regardless of active sessions. Wish me luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •