Forum

Notifications
Clear all

activex

0 Posts
2 Users
0 Reactions
157 Views
(@ccarey)
Active Member
Joined: 12 years ago
Posts: 3
Topic starter  

I would like to connect to Absolute Telnet from Excel but can't find the activex control in the registry. Does it install with AT? I also would really like to see what functions etc. the api exposes. My ultimate goal is to send commands to AT from Excel inorder to automate a connection to our database and upload subscriber information from a file.
Has anyone accomplished a connection from Excel to AT?


   
ReplyQuote
(@bpence)
Member Admin
Joined: 9 months ago
Posts: 1374
 

The ActiveX components do come with Absolute, as does a sample program called 'automation test'. I've never tried to control it from Excel, so I can't say I'm an expert. It's possible that the components may not be registered in such a way that Excel can see them.

Searching......


   
ReplyQuote
(@ccarey)
Active Member
Joined: 12 years ago
Posts: 3
Topic starter  

After scouring the internet for help and coming up empty I just dove in to see what I could make work. I was able to get Excel 2007 to connect using libabsolutetelnet but I'm a newbe to the ssh protocol. I'm going to post my code below so maybe you or someone on the forum can review and make suggestions:

What makes this all work in excel is the reference to your activex control. In the vba editor "tools" menu I select "References" and then browse to your libAbsoluteTelnet.tlb control. Once that is setup as a reference in the excel workbook the code below worked for me.

' ************* Code begins here *******************************************
'
********************************************
' Use the Absolute Telnet activex control to
' setup an SSH(2?) connection to PBS on the Cloud
' and navigate to the Subscriber Activity Import
' Utility and upload activity.
' Referneces libAbsoluteTelnet.tlb
'
********************************************
Sub SSH_Interface()
' Dimension common VT100 Commands
ESC = Chr(27) ' escape character
F1 = Chr(27) & "OP"
F2 = Chr(27) & "OQ"
F3 = Chr(27) & "OR"
F4 = Chr(27) & "OS"
F5 = Chr(27) & "om"
CU = Chr(27) & "[A" ' Cursor Up
CD = Chr(27) & "[B" ' Cursor Down
CR = Chr(27) & "[C" ' Cursor Right
CL = Chr(27) & "[D" ' Cursor Left

' define an object for absolute telnet activex
Dim objSSH2 As Object

' get the users id and password for login
Dim uid As String
Dim pw As String
frmABLogin.Show
If frmABLogin.bolCancel Then Exit Sub
uid = frmABLogin.txtABUserid.Text
pw = frmABLogin.txtABpw.Text

' Setup call back to Excel workbook
' connect Excel object to run wb.app macro
' Make sure we have Excel open with error traping
' This is actually not needed and is a relic of my CRT code which ran on the telnet app
' I left it in here as a sample how to.
On Error Resume Next
Dim app
Set app = GetObject(, "Excel.Application")
Set wb = app.Workbooks("XXX.xls")
On Error GoTo 0

' ******************************************************
' Setup the objects and variables for the Absolute Telnet
' ActiveX and open a new instance of AB for tran processing
'
******************************************************
Set objSSH2 = New LibAbsoluteTelnet.Cscrollback
With objSSH2
.SetTabTitle ("3rd party automation")
.MakeActiveTab
'.OpenLog "C:\documents and settings\myuser\desktop\ssh.log"
.SetSSHUsername (uid)
.SetSSHPassword (pw)
.SetConnectionHost ("server ip or dns")
.AsyncConnect

' ******************************************************
' The connection is open and our instance is ready to work
' for us. Send text to AB to navigate to the subscriber
' activity import and upload our activity, then exit.
'
******************************************************
x = .WaitForTimeout("5]", 10000)
If x = True Then
.SendText "1" & vbCr
Else
BadSSH "Splash screen timeout."
GoTo BadReturn
End If

' redundant code examples deleted

' The last text sent to the server disconnects
End With

' ***********************************************
' All done so tell Excel we had an upload
' Run a macro in our workbook which will enable the
' "Get Errors" button for the next step
' Since in AB we are running the code from Excel the app.run is unnessary.
' I could have simply called the "I'm done" routine. If the code were running
' in AB this would run a macro in the Excel workbook that started the ssh session
' In either case, it works. 🙂
'
***********************************************
On Error Resume Next
wb.Activate
If Err = 0 Then
app.Run "UpdateProcess"
Set wb = Nothing
Set app = Nothing
End If
On Error GoTo 0

' You may need an Exit Sub here depending on your preferences
BadReturn:
objSSH2.Disconnect
'objSSH2.CloseLog
Set objSSH2 = Nothing
End Sub

' A sub that displays our error message for user info and also including debug info.
Sub BadSSH(strErr As String)
MsgBox strErr, vbOKOnly, "SSH Error detected."
End Sub

' ********** code ends here **************************************

I attached this code to an excel button on a userform so that a mouse click will instantiate an ssh session to our server through AB and then when the session is done it will run a macro in Excel which enables the button for the next step.

I would be grateful for a review of the connection parameters. As I said above, I'm flying in the dark as far as SSH connections go.

Thanks for your reply.


   
ReplyQuote
(@bpence)
Member Admin
Joined: 9 months ago
Posts: 1374
 

You're setting tha basic connections parameters, which is what I would suspect. As long as the connection is successful, then you must have done it right. As for what happens after that, you're on your own. Screen scraping legacy applications can be a maddening experience as I'm sure you know.

Congrats on your tenacity, and let me know if there's anything I can do to help.

Brian


   
ReplyQuote
(@ccarey)
Active Member
Joined: 12 years ago
Posts: 3
Topic starter  

If you think I have a good connection then I'm going to call it finished.

Thanks for the feed back.


   
ReplyQuote
Share: