{"id":1936,"date":"2014-11-14T00:37:44","date_gmt":"2014-11-14T00:37:44","guid":{"rendered":"https:\/\/alt2.minisoft.com\/support\/?p=1936"},"modified":"2014-11-18T22:33:11","modified_gmt":"2014-11-18T22:33:11","slug":"ftp-transfer-mdmftp-and-vba","status":"publish","type":"post","link":"https:\/\/c002.minisoft.com\/support\/ftp-transfer-mdmftp-and-vba\/","title":{"rendered":"FTP Transfer (MDMFTP) and VBA"},"content":{"rendered":"<p><strong>MdmFTP in VBA<\/strong><\/p>\n<p>The MdmFTP session<br \/>\nThe MdmFTP session can be called from any Visual Basic for Applications (VBA) application.<\/p>\n<pre>Sub FTP_Upload()\r\n\r\n'Exists Action\r\nConst gcCancel = 0\r\nConst gcReplace = 1\r\nConst gcPrompt = 2\r\nConst gcAppend = 3\r\n\r\n'Direction\r\nConst gcUpload = 0\r\nConst gcDownload = 1\r\n\r\n'File Type\r\nConst gcASCII = 0\r\nConst gcBinary = 1\r\n\r\n'Host Type\r\nConst htAUTO = 0\r\nConst htUNIX = 1\r\nConst htIBM_VM = 2\r\nConst htVMS_MULTINET = 3\r\nConst htVMS_UCX = 4\r\nConst htPCTCP = 5\r\nConst htNCSA = 6\r\nConst htNOS = 7\r\nConst htQVT = 8\r\nConst htIBM_TCP = 9\r\nConst htCHAMELEON = 10\r\nConst htSUPER = 11\r\nConst htSINTFTPD = 12\r\nConst htMVS = 13\r\nConst htU5000 = 14\r\nConst htMPEIX = 15\r\nConst htSUNOS = 16<\/pre>\n<hr size=\"1\" \/>\n<p><strong> Dim FTPSession As Object<\/strong><\/p>\n<pre>On Error GoTo Egress1\r\nSet FTPSession = CreateObject(\"FTP.Session\")\r\nFTPSession.HostAddress = \"ftp_test.minisoft.com\"\r\nFTPSession.HostType = htUNIX\r\nFTPSession.LoginUser = \"neal\"\r\nFTPSession.UserPassword = InputBox(\"User Password\")\r\n\r\nIf (Not FTPSession.Connect) Then\r\nMsgBox \"1 - \" &amp; FTPSession.ErrorMessage\r\nGoTo Egress1\r\nEnd If\r\n\r\nIf (Not FTPSession.LoginStatus) Then\r\nMsgBox \"2 - \" &amp; FTPSession.ErrorMessage\r\nGoTo Egress1\r\nEnd If\r\n\r\nFTPSession.DisplayStats = True\r\nIf (FTPSession.StoreFile(\"C:\\AUTOEXEC.BAT\", \"AUTOEXEC.BAT\", gcASCII, gcReplace) &lt;&gt; 0) Then\r\nMsgBox \"3 - \" &amp; FTPSession.ErrorMessage\r\nGoTo Egress1\r\nEnd If\r\nGoTo Egress2\r\n\r\nEgress1:\r\nMsgBox \"Error Exit\"\r\n\r\nEgress2:\r\nIf FTPSession.ConnectStatus = True Then\r\nFTPSession.Disconnect\r\nEnd If\r\nSet FTPSession = Nothing\r\n\r\nEnd Sub<\/pre>\n<hr size=\"1\" \/>\n<pre>Private Sub Timer1_Timer()\r\nDim TempStr As String\r\n\r\nOn Error GoTo Egress1\r\n\r\nTimer1.Interval = 0\r\nStatusLine = \"Checking...\"\r\nList1.Text = \"\"\r\nList1.Text = FTSession.HostFileList(tHFName)\r\nIf (Len(List1.Text) = 0) Then\r\nDownloadFile\r\nElse\r\nTimer1.Interval = 1000\r\nEnd If\r\n\r\nGoTo Egress2\r\n\r\nEgress1:\r\nOn Error Resume Next\r\nMsgBox \"Error Exit\"\r\nIf FTSession.ConnectStatus = True Then\r\nFTSession.Disconnect\r\nEnd If\r\nSet FTSession = Nothing\r\nEgress2:\r\nStatusLine = \"Ready\"\r\n\r\nEnd Sub<\/pre>\n<hr size=\"1\" \/>\n<pre>Private Sub DownloadFile()\r\nDim TempStr As String\r\n\r\nStatusLine = \"Transfering...\"\r\nFTSession.DisplayStats = True\r\nFTSession.Direction = gcDownload\r\nFTSession.ExistsAction = 1\r\nTempStr = tDLName.Text\r\nIf (Len(TempStr) &gt; 1) Then\r\nFTSession.LocalFile = TempStr\r\nEnd If\r\nTempStr = tDLName.Text\r\nIf (Len(TempStr) &gt; 1) Then\r\nFTSession.HostFile = TempStr\r\nEnd If\r\nFTSession.RecordSize = 80\r\nFTSession.TransferMode = gcASCII\r\nStatusLine = \"Logon Successful - Transfering...\"\r\nIf (FTSession.StartTransfer &lt;&gt; 0) Then\r\nMsgBox \"3 - \" &amp; FTSession.ErrorMessage\r\nGoTo Egress1\r\nEnd If\r\nStatusLine = \"Transfer Complete.\"\r\n\r\nGoTo Egress2\r\n\r\nEgress1:\r\nOn Error Resume Next\r\nMsgBox \"Error Exit\"\r\nIf FTSession.ConnectStatus = True Then\r\nFTSession.Disconnect\r\nEnd If\r\nSet FTSession = Nothing\r\nEgress2:\r\nStatusLine = \"Ready\"\r\nScreen.MousePointer = 0\r\n\r\nEnd Sub<\/pre>\n<hr noshade=\"noshade\" size=\"1\" \/>\n<pre>!JOB VBJOB2,MGR\/password.MINISOFT\r\n!CONTINUE\r\n!PURGE VBJOB3\r\n!COPY NPREADME,VBJOB3\r\n!PURGE VBJOB1\r\n!SET STDLIST=DELETE\r\n!EOJ<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>MdmFTP in VBA The MdmFTP session The MdmFTP session can be called from any Visual Basic for Applications (VBA) application. Sub FTP_Upload() &#8216;Exists Action Const gcCancel = 0 Const gcReplace = 1 Const gcPrompt = 2 Const gcAppend = 3 &#8216;Direction Const gcUpload = 0 Const gcDownload = 1 &#8216;File Type Const gcASCII = 0 [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,54],"tags":[],"_links":{"self":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1936"}],"collection":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=1936"}],"version-history":[{"count":1,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1936\/revisions"}],"predecessor-version":[{"id":1937,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1936\/revisions\/1937"}],"wp:attachment":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=1936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=1936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=1936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}