none
Proper Syntax or Other Error? Website Login and Upload Text Macro. RRS feed

  • Question

  • I am creating a VBA macro in excel to open a website, login to the website, navigate to a directory, then upload a text file. I get an error at the line...

    Set ipf = IE.document.all.Upload File

    My assumption is because the website has been gracious enough to name the directory with a SPACE in the name. Is there a way to overcome this?

    Full code below...


    <Begin Code>
    Sub SendFile()

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.navigate "https://ftp.website.com"


    Do
            If IE.readyState = 4 Then
                IE.Visible = True


                Exit Do
            Else
                DoEvents
            End If
        Loop

    Set ipf = IE.document.all.user
    ipf.Value = "username"
    Set ipf = IE.document.all.pass
    ipf.Value = "password"
    Set ipf = IE.document.all.Switch
    ipf.Click
    Application.Wait (Now + TimeValue("0:00:02"))
    IE.Visible = True

    IE.navigate "https://ftp.filedirectory.com/files"

    Set ipf = IE.document.all.File
    ipf.Value = "C:\Users\Documents\test.txt"
    SYNTAX ERROR IS HERE--->Set ipf = IE.document.all.Upload File
    ipf.Click


    End Sub

    <End Code>

    Thank you for taking the time to read my question.

                            
    • Moved by Steve Fan Friday, March 10, 2017 3:31 AM
    Thursday, March 9, 2017 7:13 PM

All replies

  • Hi Bill,

    Thanks for visiting our forum.

    Then this forum mainly focus on general questions related to Excel. Since your issue is about VBA macros, I'll move your thread to the following dedicated MSDN forum for VBA:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, March 10, 2017 3:28 AM
  • Apologies, sometimes when I post the forum location changes from where I was just reading.
    Thursday, March 16, 2017 4:19 PM
  • It looks like you are trying to ftp files.  IE uses a dll called wininet.dll to ftp files.  I've used win32 calls to wininet to upload/download files with great success.  I've never used it from MS Internet Controls.  Look at this.
    Thursday, March 16, 2017 4:56 PM