+ Reply to Thread
Results 1 to 3 of 3

Excel VBA upload via SFTP

Hybrid View

  1. #1
    Registered User
    Join Date
    03-30-2020
    Location
    Utrecht
    MS-Off Ver
    2010
    Posts
    1

    Excel VBA upload via SFTP

    Dear members,

    In the past I used this code below to automatically upload files to my FTP. Now I moved to SFTP and it doesnt work anymore.

    Does someone know how to upload to #SFTP via VBA?

    Thanks and have a nice day,

    Ronald


    Dim TempChart As Variant
    Dim ImageName1 As String
    Dim ImageName As String
    Dim FinalImagePath As String
    Dim InRange As Range
    Dim DiscName As String
    Dim ftpLogin As String
    Dim ftpPassword As String
    Dim ftpPath As String
    Dim a As Object
    Dim fs As Object
    Dim ftpSite As String
    Dim TempFolderName As String
    
    
    '---------------------------------------------------------------------------------
    'set variable parameters
    TempFolderName = "zqqftptemp"
    DiscName = "C" 'put the name of disc for temporary files, for example "D".
    ftpSite = "xxxxxxx 'put the website name, for example "mywebsite.com"
    ftpPath = "/articles" 'put the path to ftp folder, for example "/public_html/uploaded_files/"
    ftpLogin = "xxxxx" 'put your ftp login, for example "john123"
    ftpPassword = "xxxxxxx" 'put your ftp password, for example "pass123"
    '---------------------------------------------------------------------------------
    
    Application.ScreenUpdating = False
    
    'copy the appropriate range
    Workbooks("Outlook lists.xlsm").Activate
    Worksheets("csv").Range("A1:P11").Copy
    
    
    'export as an image
    MkDir DiscName & ":\" & TempFolderName & "\"
    FinalImagePath = DiscName & ":\" & TempFolderName & "\" & "outlooks.csv"
    
    'add new workbook and paste copied range
    Workbooks.Add
    ActiveSheet.Paste
    Last edited by Ronaldkok; 03-30-2020 at 07:51 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,658

    Re: Excel VBA upload via SFTP

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Excel VBA upload via SFTP

    To upload file to sftp you'd want 3rd party library, such as WinScp.

    Have a read of link below.
    https://winscp.net/eng/docs/library_vb

    Edit: Alternately you can use WinScp's command line tool via shell, similar to post#7 of the link below.
    https://www.access-programmers.co.uk...ss-vba.280970/
    Last edited by CK76; 03-30-2020 at 08:10 AM.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Downloading file from SFTP
    By paulzov in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2018, 05:20 PM
  2. Problem uploading file to sftp
    By Eliot Y in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2015, 08:21 AM
  3. upload/download files to/from sftp
    By sujithy007 in forum Microsoft Windows Help
    Replies: 2
    Last Post: 08-27-2014, 08:29 AM
  4. Using files from an SFTP as a dynamic data source
    By paulzov in forum Access Tables & Databases
    Replies: 1
    Last Post: 05-01-2014, 07:10 PM
  5. Unable to upload files to upload center
    By GeekoMania in forum Office 365
    Replies: 0
    Last Post: 09-11-2013, 03:18 AM
  6. Need to modify VBA macro from ftp to sftp
    By nileshbhaw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2013, 08:23 AM
  7. How to Change Excel Marco upload from FTP to SFTP?
    By triniti in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2012, 08:14 AM

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