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!

vba question

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
hi,

i generated the following code in my previos post which works fine in extra. now, i'm trying the same thing using excel vba but unfortunately the coding is not the same. i get a "compile error: expected:lib"
is this something simple to fix and implement?
i'm not familiar with doing this using vba.

thanks
zach


Code:
Declare Function DisplayChoice(szLocale$) As String
                               
Sub Main
Dim szLocation$
Dim iDone%
Dim DroplistBox as string
Dim Sys As Object, Sess As Object
Set Sys = CreateObject("Extra.System")
Dim SessionNames() As String
SessionCount = Sys.Sessions.Count
For SessionCnt = 0 To Sys.Sessions.Count
ReDim Preserve SessionNames(SessionCnt)
SessionNames(Sessioncnt) = Sys.Sessions.Item(SessionCnt).Name
Next

        Begin Dialog dlgHouseSample 0, 1, 175, 93, "Please Select a Session to Run Macro"
           ButtonGroup .ButtonPressed
           
           OkButton  100, 15, 50, 14
           CancelButton  100, 35, 50, 14
           PushButton   100, 55, 50, 14, "&Reset", .btnReset
           
           Text  12, 5, 62, 9, "Available Sessions"
           DropComboBox 10, 15,65,55, SessionNames(), .dcbLocation
        
        End Dialog

    iDone = FALSE

    While (iDone = FALSE)    
        Dim dMain as dlgHouseSample

        nRet = Dialog(dMain)
        
        Select Case nRet
            Case -1                       ' -1 is returned if the user chose OK
                iDone = TRUE
                szLocation = dMain.dcbLocation
                
        If SzLocation = "" Then
        MsgBox "You Didn't Select a Session. Please start over"
        Exit Sub
        End If
      
    Set Sess = Sys.ActiveSession
    For i=1 to Sys.Sessions.Count
        If SzLocation = Sys.Sessions.Item(i) Then
        Set Sess=Sys.Sessions.Item(i)
        MsgBox "Activating session " + Sess.Name + "."
        Sess.Activate
        Exit For
        End If
    Next
                
            Case 0                        ' 0 is returned if the user chose Cancel
                iDone = TRUE
            msgbox "Please select a Session"    
            
            Case 1                        ' 1 is returned if the user chose Reset
                dMain.dcbLocation = ""
               
            Case Else
                msgbox "Some undefined button pressed " + str(dMain.ButtonPressed)
                
        End Select
    Wend

End Sub

'--------------------------------------------------------------------------------
Function DisplayChoice(szLocale$) As String

szResult = szLocale

DisplayChoice = szResult
    

End Function
 




You may need to reference the Attachmate!Extra Object Library Tools > References

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
hi Skip,

i tried that but am still receiving the same error. i think i need to learn using a userform...

thanks
zach
 
Yes, the EB Dialog box needs to be converted to a VBA Form.

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top