+ Reply to Thread
Results 1 to 1 of 1

Trying to submit a filename to a website form for upload.

Hybrid View

mctabish Trying to submit a filename... 01-12-2010, 11:59 PM
  1. #1
    Registered User
    Join Date
    11-01-2009
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    47

    Unhappy Trying to submit a filename to a website form for upload.

    There is a site on our company's INTRANET that I need to upload a file to.
    This is a FORM that needs the fileName to be populated, but I have not been able to get it to accept fileName from any means I have tried. I have ALL of the other fields working and it is to the point all I need to do is manually select the file, but I need to automate this.

    I have been able to access the site, stuff all kinds of other info into the websites varables, but I have NOT been able to stuff the fileName to upload.
    Here is the code (including some failed attempts) to get the file name into the web page.
    First, I am opening the page and logging in with a userform ("fNTLogin")


    Function ProcessScout() As Boolean
        Dim oScout As Object
        Dim ScoutWeb As String
        Dim fileName As String
        Dim newscoutname As String
        Dim F As fNTLogin 
        'name of the file to upload
        newscoutname = "h:\Scout\ScoutInPut" & Application.Substitute(Format(Date, “yyyymmdd”), "/", "-") & ".txt" 
    
        GetAccountList 'function to get a list of account numbers
        ScoutWeb = "http://internalWebsite.com/network_monitoring/servlet/network_monitoring"
        Set oScout = OpenScout(ScoutWeb) 'opens the site and gets the object 'oScout'
        'waitforweb2 (oScout)
                While oScout.busy
            DoEvents
        Wend
        While oScout.ReadyState <> 4
            DoEvents
        Wend
        spage = oScout.document.DocumentElement.outerHTML ' the the outer html for testing purposes
        webWait = oScout.document.Title
    
    'test for logged in
        If InStr(spage, "Please enter your NT user name and password") > 0 Then
    'login
        Do While InStr(spage, "Please enter your NT user name and password") > 0
         Set F = New fNTLogin  'Creates the login form
              F.Value1 = ""  'set username value to ""
              F.Value2 = ""  'set password value to ""
              F.Display  'shows the form
              pub_UserName = F.Result1 'sets the username for other logins
              pub_pw = F.Result2  'sets the pw for other logins
             Set F = Nothing 'distroys the form
             With oScout.document.form1
            .all.Item("user").Value = pub_UserName
            .all.Item("pass").Value = pub_pw
            .Submit
        End With
        While oScout.busy
            DoEvents
        Wend
        While oScout.ReadyState <> 4
            DoEvents
        Wend
        spage = oScout.document.DocumentElement.outerHTML 'resetting spage for testing if logged in
    Loop
           
        End If
      ' We are now logged in    
        oScout.Navigate "http://internalwebsite.com:8070/network_monitoring/servlet/network_monitoring?reqType=cmLookupPage" ' move to the page to upload account info
       While oScout.busy
            DoEvents
        Wend
        While oScout.ReadyState <> 4
            DoEvents
        Wend
        oScout.document.form1.searchType.Value = "bulkaccount"
        oScout.document.form1.bulkLoadType.Value = "account"
        oScout.document.getElementById("divMAC").Style.visibility = "hidden"
        oScout.document.getElementById("divPhone").Style.visibility = "hidden"
        oScout.document.getElementById("divAccount").Style.visibility = "hidden"
        oScout.document.getElementById("divNode").Style.visibility = "hidden"
        oScout.document.getElementById("divBulkMAC").Style.visibility = "visible"
        oScout.document.form1.Mac.Value = ""
        oScout.document.form1.account.Value = ""
        oScout.document.form1.phone.Value = ""
        oScout.document.form1.Node.Value = ""
        oScout.document.form1.reqType.Value = "onDemandBatch"
        oScout.document.form1.Encoding = "multipart/form-data"
    
        With oScout.document.form1  'document name = "document" form name = "form1"
            .report(3).Click 'select the third report option  'this works
            .Email.Value = "Bruce_Johnson7@internalwebsite.com" ' this works
            .FileName.Value = "H:\Scout\ScoutInPut1-7-2010.txt"    'this does not error, but it does not stuff the name
        End With
        
      '  UploadFile oScout,  "H:\Scout\ScoutInPut1-7-2010.txt", "fileName" ' another failed attempt
    
    'Failed attempt below
     '      Set Files = oScout.document.getElementsByTagName("input")
     '      For Each File In Files
     '      
     '           If File.Type = "file" Then
     '               If SetFeatureTo Then
     '                   check.Checked = True
     '                  ' Exit Sub
     '               Else
     '                  ' check.Checked = False
     '                  ' Exit Sub
     '               End If
     '           End If
     '    '   End If
     '    '   r = check.Value
     '   Next
    
        
        oScout.document.form1.fileName.Value = "H:\Scout\ScoutInPut1-7-2010.txt" ' no errors but does not populate     Call setfeature(oScout, "billing", True)
        Call setfeature(oScout, "ecx", True)
        Call setfeature(oScout, "gds", True)
        Call setfeature(oScout, "bacc", True)
        Call setfeature(oScout, "switch", True)
        With oScout.document.form1
            .all.Item("fileName").Value = "H:\Scout\ScoutInPut1-12-2010.txt"
            
            '.all.Item("pass").Value = pub_pw
            '.Submit.Click
        End With
        
        MsgBox "Please select file and pres Submit"   '<< this is to handle it in the 
                    'meantime until I get the stuffing of the file name working
        oScout.document.form1.Submit
        spage = oScout.document.DocumentElement.Title
        Debug.Print spage
    
        webWait = oScout.document.Title
    
    End Function

    Here is the webpage html code that needs to recieve the filename:

    Enter Email Address:<br>
    <input type=text size=25 name=email value=""><br><br>
    Select File To Upload:<br>
    <input type=file name=fileName><br>


    Thanks
    Bruce
    Last edited by mctabish; 01-14-2010 at 08:38 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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