My goal is to figure out a way to add a progress bar to an already existing FTP script that is running in VBScript. This script currently runs fine just FTPing the file(s), but I would like to be able to see a progress bar that shows how far along the transfer is.
<----------------- BEGIN ------------------->
sub MultipleFileFTP
Dim vbYesNoCancel: vbYesNoCancel = 3
Dim vbQuestion: vbQuestion = 32
Dim vbYes: vbYes = 6
Dim vbNo: vbNo = 7
Dim vbCancel: vbCancel = 2
FTPFile = "c:\ftpscript.txt"
set fso = CreateObject("Scripting.FileSystemObject")
set ws = CreateObject("WScript.Shell")
set qallist=ActiveDocument.Fields("Quote").GetPossibleValues
Quotes=qallist.Item(0).Text
set ftpfromallist=ActiveDocument.Fields("Document FTP Name").GetPossibleValues
set ftptoallist=ActiveDocument.Fields("New Document Launch Name").GetPossibleValues
set tofolderlist=ActiveDocument.Fields("New Folder Launch Name").GetPossibleValues
set docsizelist=ActiveDocument.Fields("Document Size").GetPossibleValues
'Open file with 2(write) initializes the file and erases any existing data
if fso.FileExists(FTPFile) then
set open_file = fspenTextFile(FTPFile, 2)
else
set open_file = fspenTextFile(FTPFile, 2, "True")
end if
open_file.WriteLine "open ftp.mysite.com"
open_file.WriteLine "myuser"
open_file.WriteLine "mypass"
for f=0 to tofolderlist.Count-1
newfolder=tofolderlist.Item(f).Text
if fso.FolderExists("C:\Download Folder") then
else
fso.CreateFolder("C:\Download Folder")
end if
if fso.FolderExists("C:\Download Folder\" & newfolder) then
else
fso.CreateFolder("C:\Download Folder\" & newfolder)
end if
next
for i=0 to ftpfromallist.Count-1
FTPFrom=ftpfromallist.Item(i).Text
FTPTo=ftptoallist.Item(i).Text
filesize=docsizelist.Item(i).Number
totalsize=totalsize + filesize
open_file.WriteLine "get " & Quotes & FTPFrom & Quotes & " " & Quotes & FTPTo & Quotes
next
open_file.WriteLine "QUIT"
open_file.Close()
rtnvalue = msgbox ("The size of the file(s) you wish to download is " & FormatNumber(totalsize/1048576,0) & " Mbytes", vbYesNoCancel + vbQuestion)
if rtnvalue = 6 then
'FTP the file
retmsg = ws.Run("ftp -s:"& Quotes & FTPFile & Quotes,1,"TRUE")
if retmsg = 0 Then
MsgBox("The FTP process has completed normally...")
Else
MsgBox("Error, the FTP process has NOT completed." & CHR(13) & "Please check your input and try again.")
End If
End if
end sub
<----------------- END ------------------->
Thanks
Oz
<----------------- BEGIN ------------------->
sub MultipleFileFTP
Dim vbYesNoCancel: vbYesNoCancel = 3
Dim vbQuestion: vbQuestion = 32
Dim vbYes: vbYes = 6
Dim vbNo: vbNo = 7
Dim vbCancel: vbCancel = 2
FTPFile = "c:\ftpscript.txt"
set fso = CreateObject("Scripting.FileSystemObject")
set ws = CreateObject("WScript.Shell")
set qallist=ActiveDocument.Fields("Quote").GetPossibleValues
Quotes=qallist.Item(0).Text
set ftpfromallist=ActiveDocument.Fields("Document FTP Name").GetPossibleValues
set ftptoallist=ActiveDocument.Fields("New Document Launch Name").GetPossibleValues
set tofolderlist=ActiveDocument.Fields("New Folder Launch Name").GetPossibleValues
set docsizelist=ActiveDocument.Fields("Document Size").GetPossibleValues
'Open file with 2(write) initializes the file and erases any existing data
if fso.FileExists(FTPFile) then
set open_file = fspenTextFile(FTPFile, 2)
else
set open_file = fspenTextFile(FTPFile, 2, "True")
end if
open_file.WriteLine "open ftp.mysite.com"
open_file.WriteLine "myuser"
open_file.WriteLine "mypass"
for f=0 to tofolderlist.Count-1
newfolder=tofolderlist.Item(f).Text
if fso.FolderExists("C:\Download Folder") then
else
fso.CreateFolder("C:\Download Folder")
end if
if fso.FolderExists("C:\Download Folder\" & newfolder) then
else
fso.CreateFolder("C:\Download Folder\" & newfolder)
end if
next
for i=0 to ftpfromallist.Count-1
FTPFrom=ftpfromallist.Item(i).Text
FTPTo=ftptoallist.Item(i).Text
filesize=docsizelist.Item(i).Number
totalsize=totalsize + filesize
open_file.WriteLine "get " & Quotes & FTPFrom & Quotes & " " & Quotes & FTPTo & Quotes
next
open_file.WriteLine "QUIT"
open_file.Close()
rtnvalue = msgbox ("The size of the file(s) you wish to download is " & FormatNumber(totalsize/1048576,0) & " Mbytes", vbYesNoCancel + vbQuestion)
if rtnvalue = 6 then
'FTP the file
retmsg = ws.Run("ftp -s:"& Quotes & FTPFile & Quotes,1,"TRUE")
if retmsg = 0 Then
MsgBox("The FTP process has completed normally...")
Else
MsgBox("Error, the FTP process has NOT completed." & CHR(13) & "Please check your input and try again.")
End If
End if
end sub
<----------------- END ------------------->
Thanks
Oz