×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Not able to run Extra macro from VBA editor(Excel)

Not able to run Extra macro from VBA editor(Excel)

Not able to run Extra macro from VBA editor(Excel)

(OP)
Hi Everyone,

I am facing problem in not being able to run Extra macro from vba editor(excel).


Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
    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
    
    MsgBox Sessions.Count

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

    g_HostSettleTime = 10000     ' milliseconds

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

    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    If (Sess0 Is Nothing) Then
        MsgBox "Could not create the Session object.  Stopping macro playback."
        Stop
    End If


I am always getting the error : "Could not create the Session object.  Stopping macro playback."

Any clues?

RE: Not able to run Extra macro from VBA editor(Excel)



hi,

Do you have a Session opened already in Attachmate, when you run this macro?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Not able to run Extra macro from VBA editor(Excel)

(OP)
Hi SkipVought,

Yes session is open but i am getting the error: Could not create the Session object.  Stopping macro playback.

When i run the same script from Attachmate Macro editor it is running fine.

RE: Not able to run Extra macro from VBA editor(Excel)




Do you really need the Sessions object, as you are later setting the Sess0 to the active session?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Not able to run Extra macro from VBA editor(Excel)

(OP)
Thanks SkipVought for the reply..

Msgbox System.Sessions.count prints the value as "0" while there are two active sessions open.

I need to send some data to any open active session.

I dont need Sessions object if activesession is returned from System object.

RE: Not able to run Extra macro from VBA editor(Excel)



I just ran your code as posted from Excel 2007 VB Editor.  I did NOT run the code in Extra Basic; rather in Excel VBA.  The only changes I had to make were to 1) change Global to Public for your two global variables and 2) declare the OldSystemTimeout& variable, since I have Option Explicit set in the VB Editor in Excel.

I make EXCLUSIVE use of Excel VBA rather than Extra VB, because I prefer to drive a Lamborghini than a Yugo. The analogy is palpable.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Not able to run Extra macro from VBA editor(Excel)



BTW, I can duplicate your symptoms EXACTLY, by NOT opening an Extra!Attachmate session, and then running your code.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Not able to run Extra macro from VBA editor(Excel)

(OP)
SkipVought,

When i run the same code in Excel 2003 VBA Editor, it is working perfectly..

I don't know what is wrong with the Excel 2007.

Your analogy is real regarding Extra macro vs VB Macro :)
 

RE: Not able to run Extra macro from VBA editor(Excel)

Hi Deter

I'm not very experianced with macro's between excell an
and attachmate however here is some code which I sharing data between attachmate screens and excell and works fine

Sub Macro Name()
'--------------------------------------------------------------------------------
' 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 = 0     ' milliseconds

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

' Get the necessary Session Objects
  Dim Sess0 As Object
       SessName0$ = "C:\Program Files\Attachmate\EXTRA!\Sessions\Attachmate session name.EDP"
    
    Set Sess0 = Sessions.Item(SessName0$)
    If Sess0 Is Nothing Then
        Err = MsgBox(SessName0 + " is not currently open.  Open it?", 1)
        If 1 = Err Then
            Err = 0
            Set Sess0 = Sessions.Open(SessName0)
            If Err Then
                MsgBox ("Failed to open " + SessName0 + ".  Stopping playback")
                Stop
            End If
        ElseIf 2 = Err Then
            Stop
        Else
            MsgBox ("Failed to open " + SessName0 + ".  Stopping playback")
            Stop
        End If
    End If
    If Not Sess0.Visible Then Sess0.Visible = True
    Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
    
    Dim Sess1 As Object
    SessName1$ = "\\NA-11\burrowr6\My Documents\Programs\Billing\2nd Attachmate session name name.EDP"
    
    Set Sess1 = Sessions.Item(SessName1$)
    If Sess1 Is Nothing Then
        Err = MsgBox(SessName1 + " is not currently open.  Open it?", 1)
        If 1 = Err Then
            Err = 0
            Set Sess1 = Sessions.Open(SessName1)
            If Err Then
                MsgBox ("Failed to open " + SessName1 + ".  Stopping playback")
                Stop
            End If
        ElseIf 2 = Err Then
            Stop
        Else
            MsgBox ("Failed to open " + SessName1 + ".  Stopping playback")
            Stop
        End If
    End If
    If Not Sess1.Visible Then Sess1.Visible = True
    
    Dim Excel As Object
    Dim Session As Object
    Dim MyScreen As Object

RE: Not able to run Extra macro from VBA editor(Excel)

(OP)
Thanks guys,

Sorry for late reply..I found out the problem.

I was running the above pasted code in Excel 2007 but when i run the same code in excel 2003 it was working fine.

Thanks
Deter

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close