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

Access: Screen Scraped from EXTRA! X-treme... 1

Status
Not open for further replies.

Sosul

Technical User
Jul 2, 2007
14
US
So I hear that you guys are the experts...

I have the following code that doesn't seem to work anymore. I want it to set the current session of Extra that is open, instead it opens another session of EXTRA which isn't even the same application that I want to use.

The same of the application that is open is MCSmod4, this code will open MAINFRAME.

Any help?

Code:
Private Sub Command0_Click()

'On Error GoTo Errorhandler

' Get the main system object
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")   ' Gets the system object
    If (System Is Nothing) Then
        MsgBox "Could not create the EXTRA System object.  Stopping macro playback."
        Stop
    End If
    Set Sessions = System.Sessions

    If (Sessions Is Nothing) Then
        MsgBox "Could not create the Sessions collection object.  Stopping macro playback."
        Stop
    End If

' Set the default wait timeout value
   g_HostSettleTime = 1000     ' milliseconds

   OldSystemTimeout& = System.TimeoutValue
   If (g_HostSettleTime > OldSystemTimeout) Then
       System.TimeoutValue = g_HostSettleTime
   End If

' Get the necessary Session Object
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    If (Sess0 Is Nothing) Then
        MsgBox "Could not create the Session object.  Stopping macro playback."
        Exit Sub
    End If
    If Not Sess0.Visible Then Sess0.Visible = True
    Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
 
If you know the name of the already running session you can use.

Dim Sess As Object
Set Sess = GetObject("yourdrive\yourpath\yoursession.EDP")



[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Sosul,
And if there is only one instance of Extra running you can get the object by class:
Code:
...
    Dim System As Object
    [s]Set System = CreateObject("EXTRA.System")   ' Gets the system object[/s]
    Set System = [b]GetObject(, "EXTRA.System")[/b]
...

Keep in mind that if there are multiple instaces of Extra running there is no telling which instace will be returned.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Ok I think that worked for setting the system, now it's erroring on this code.

Code:
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    If (Sess0 Is Nothing) Then
        MsgBox "Could not create the Session object.  Stopping macro playback."
        Exit Sub
    End If
    If Not Sess0.Visible Then Sess0.Visible = True

It's erroring on:

Code:
[COLOR=red]
  Set Sess0 = System.ActiveSession
[/color]
 
'try something like this to see if the session your expecting is actually open


Dim System As Object
Set System = GetObject(, "EXTRA.System")

For SessCnt = 0 to System.Sessions.Count
MsgBox System.Sessions.Item(SessCnt).Name
next


[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Says variable not defined.

I started to Dim SessCnt as Double, but didn't work.
 
Do eitehr of these work? I don't know what number the sessions start at. If they start at 0 then you need to go to the count - 1, otherwise you'll get an error after the last session. If they start at 1, then you'll get an error on the 0 session.

For SessCnt = 0 to System.Sessions.Count - 1
MsgBox System.Sessions.Item(SessCnt).Name
Next

For SessCnt = 1 to System.Sessions.Count
MsgBox System.Sessions.Item(SessCnt).Name
next
 
Did not work. Did is what I have and it errors on For SessCnt


Code:
Private Sub Command45_Click()
Dim System As Object

Set System = GetObject(, "EXTRA.System")

For SessCnt = 1 To System.Sessions.Count
    MsgBox System.Sessions.Item(SessCnt).Name
Next


End Sub
 
What happens if you nix the for loop and simply ask for the sessions?

Code:
Private Sub Command45_Click()
Dim System As Object

Set System = GetObject(, "EXTRA.System")
If System Is Nothing Then
    MsgBox "No Extra object"
Else
    MsgBox System.Sessions.Item(0).Name
    MsgBox System.Sessions.Item(1).Name
End If
End Sub
 
Run-time error '429':
ActiveX component can't create object.

Any ideas?
 
Does it give you a line for the error? And does this work?

Code:
Private Sub Command45_Click()
  Dim System As Object
  Set System = GetObject(, "EXTRA.System")
  If System Is Nothing Then
    MsgBox "No Extra object"
  Else
    MsgBox System.Sessions.Count
  End If
End Sub
 
This is the line that it errors on:

Code:
Set System = GetObject(, "EXTRA.System")


Errors on same line with same message with above code.
 
Sosul,
Since your using [tt]GetObject()[/tt] it might be worth starting with step 1.

Please don't be insulted by this question: Do you have an Extra window open and connected when you run the code provided by Skie?

CMP
 
I do believe so.

I was trying to attach a screenshot to show you the properties of the application. But couldn't figure out how to.

Under Target type it says: EXTRA! Session
Under Target location it says: Sessions

I'm not insulted at all CautionMP, anything that I can do to help you guys help me, I'll do it.
 
Let's try this.

screenshot.jpg
 
Is there something that I can check to see if maybe the company's system people have blocked access that will allow VB to get the system object?
 
Try this:
Code:
Sub TryThis
  Dim System As Object
  Set System = CreateObject("EXTRA.System")
  If Not System Is Nothing Then
    MsgBox System.Sessions.Count
  End If
End Sub
 
Ok I got a message box with a 1 in it.
 
Is this the session you are running?
Code:
Sub TryThis
  Dim System As Object
  Set System = CreateObject("EXTRA.System")
  If Not System Is Nothing Then
    For i = 1 to System.Sessions.Count
      MsgBox System.Sessions.Item(i)
    Next
  End If
End Sub
 
That pulls up a different session, it's called Mainframe.

The one I want is already open and it's called MCSmod4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top