+ Reply to Thread
Results 1 to 2 of 2

Entering password that refreshes data from FTP macro

Hybrid View

  1. #1
    Registered User
    Join Date
    08-18-2015
    Location
    Birmimgham
    MS-Off Ver
    2015
    Posts
    78

    Entering password that refreshes data from FTP macro

    Hi. I have a macro that simply refreshes data from a FTP server using the command ActiveWorkbook.RefreshAll however it prompts for the FTP password every time the work book is opened. How can I enter the password in the macro so it refreshes automatically without the need to enter anything? Also can I add a specific time so the macro runs automatically?

  2. #2
    Registered User
    Join Date
    09-13-2012
    Location
    Queensland
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Entering password that refreshes data from FTP macro

    mate, this is very common question, a simple google search would have given you the answer

    see code below

    Sub Get_File_From_FTP()
        'Variable Declarion Section
        Dim FTP As Inet
        
        'Assign Host URL, Source and Destination File path
        HostURL = ThisWorkbook.Sheets(1).Cells(1, 1)
        FileSource = ThisWorkbook.Sheets(1).Cells(1, 2)
        FileDestination = ThisWorkbook.Sheets(1).Cells(2, 2)
        
        'Create New instance of Object and Assign the Parameters
        Set FTP = New Inet
        With FTP
            .URL = HostURL
            .Protocol = icFTP
            'Replace with your Login and Password Below. Many FTP servers allow Anonymous access with below credentials
            .UserName = "anonymous"
            .Password = "[email protected]"
            .AccessType = icUseDefault
            'Use "Get" to Download and "Put" Option to Upload File to FTP Server
            .Execute .URL, "Get " & FileSource & " " & FileDestination
        End With
        Do While FTP.StillExecuting
            DoEvents
        Loop
        
        'Status of FTP through Voice Message
        Application.Speech.Speak "Process Completed;" & FTP.ResponseInfo
        
        If FTP.ResponseCode = 0 Then
            'SomeTime FTP steps will execute successfully, but file will not be there in Destination path
            'Search for the file in the Path mentioned in this Message Box
            MsgBox "File is Copied to :" & VBA.CurDir
        End If
        Set FTP = Nothing
    End Sub

+ 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. [SOLVED] A macro for calculating mean of value across 1000 random trials(refreshes)
    By ugalskov in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2016, 09:27 AM
  2. [SOLVED] Macro that refreshes pivot tables
    By Sgligori in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-12-2015, 11:16 PM
  3. Ask for password before entering data into cell
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 08:57 PM
  4. Save old data when web query refreshes
    By BlakeCrossley in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-19-2012, 01:54 PM
  5. Entering a username and password while downloading a file in a Excel macro
    By koltregaskes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2011, 08:44 AM
  6. Macro that refreshes/sort information
    By SeanKosmann in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-27-2010, 04:01 PM
  7. Stock Macro for web query refreshes
    By mtj2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2008, 02:44 AM

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