Starting a Telnet session from VBA

I have a VBA library that does FTP, I would also like to make telnet. At the moment, I am cheating on a Perl script that makes telnet based on a text file, but I would like to connect a telnet connection from inside VBA. Does anyone have a source for this? I do not want to use an add-in, I need code to be standalone.

+5
source share
1 answer

If you can use the MS WinSock control (also see using winsock in VBA )

Additional resources:

MSDN Library: Using Winsock Control

(Visual Basic) Winsock Control

, cmd.exe SendKeys, :

: VBA.

sub telNETScript()
On Error Resume Next
Dim WshShell as object

set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000

'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet xx.xx.xx.73 9999"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000

'Step 2 - Issue Commands with pauses'
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "5"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000

'Step 3 - Exit Command Window
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Quit

end sub

SendKeys - , , , 12 .

:

Telnet Excel - Microsoft.excel.programming

Telnet VBScript

0

All Articles