+ Reply to Thread
Results 1 to 2 of 2

Specifying an FTP Folder while uploading from VBA

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    Grapevine, TX
    MS-Off Ver
    Excel 2010
    Posts
    2

    Specifying an FTP Folder while uploading from VBA

    Hi,

    I browsed through this post
    http://www.excelforum.com/excel-prog...to-an-ftp.html

    and it got me to 99% of the way. But there was a question in the replies that remained unanswered. How do I specify which folder within the ftp site I need to put the file in. (I only have access to certain folders on the ftp site)

    Thanks,

    Parker

  2. #2
    Registered User
    Join Date
    09-26-2012
    Location
    Grapevine, TX
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Specifying an FTP Folder while uploading from VBA

    I solved it by playing around with the code. Here is the answer

    Step 1
    Add the following function to the top portion of the code just above the 'Close the Internet Object' comment

    Private Declare Function FtpSetCurrentDirectory _
    Lib "wininet.dll" _
    Alias "FtpSetCurrentDirectoryA" _
    (ByVal hFtp As Long, _
    ByVal lpszDirectory As String) As Long

    Step 2
    Then put the following in the bottom portion of the code (The UploadFTP subroutine)
    Dim DirectoryName as String
    Dim Ret as long

    Step 3
    Below the Password = .... statement
    DirectoryName = "XYZ\ABC" (replace with your own directory names)

    Step 4
    Just above the "Success = ...." code, put
    Ret = FtpSetCurrentDirectory(INetConn, DirectoryName)

    Step 5
    Modify "If Success <>0 Then" to
    "If Success <> 0 And Ret <> 0 Then"


    That's it! Good Luck!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1