Underc0de

Foros Generales => Dudas y pedidos generales => Mensaje iniciado por: Atomic en Enero 28, 2016, 01:42:12 PM

Título: Ayuda con VBA en excel
Publicado por: Atomic en Enero 28, 2016, 01:42:12 PM
Buenos dias,

He estado tratando de hacer un excel que al momento de abrirlo capture la información del sistema mediante un shell y lo guarde en un txt en mis documentos, y que ya guardado ese txt lo suba a un servidor FTP o lo envie por correo.

Hasta el momento solo tengo el script VBA para generar el txt con el SYSTEMINFO pero no se como enviarlo via FTP o mail.

Entontre este script para el upload ftp pero no se como adaptarlo:

Código (vb) [Seleccionar]

Public Sub FtpSend()

Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long

vPath = ThisWorkbook.Path
vFile = "YourFile.csv"
vFTPServ = "********"

'Mounting file command for ftp.exe
fNum = FreeFile()
Open vPath & "\FtpComm.txt" For Output As #fNum
Print #1, "user ***** *****" ' your login and password"
Print #1, "cd TargetDir"  'change to dir on server
Print #1, "bin" ' bin or ascii file type to send
Print #1, "put " & vPath & "\" & vFile & " " & vFile ' upload local filename to server file
Print #1, "close" ' close connection
Print #1, "quit" ' Quit ftp program
Close

Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ, vbNormalNoFocus

SetAttr vPath & "\FtpComm.txt", vbNormal
Kill vPath & "\FtpComm.txt"

End Sub


Si alguien me pudiera orientar a adaptarlo, se los agradecería mucho. Gracias