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

mctabish

New Member
Joined
Nov 2, 2009
Messages
33
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.
confused.gif
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")
Code:
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


<TABLE class=tborder id=post2231804 cellSpacing=0 cellPadding=6 width="100%" align=center border=0><TBODY><TR><TD class=thead>
</TD></TR><TR><TD class=alt2 style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"><!-- user info --><TABLE cellSpacing=6 cellPadding=0 width="100%" border=0><TBODY><TR><TD noWrap> </TD><TD width="100%"></TD><TD vAlign=top noWrap>
</TD></TR></TBODY></TABLE><!-- / user info --></TD></TR><TR><TD class=alt1 id=td_post_2231804><!-- message, attachments, sig --><!-- icon and title -->



</PRE>

<!-- END TEMPLATE: bbcode_code --></P>Here is the webpage html code that needs to recieve the filename:
Code:
  function validateBulkEntry() {
    var isContinue = true;
    var name = document.form1.fileName.value;
    var email = document.form1.email.value;
    if(email.length == 0) {
      alert("Please enter an email address in Step #4.  This is where notification will be sent when your results are ready.");
    }
    else if(name.length > 0) {
      name = name.toLowerCase();
      var myIndex = name.indexOf(".doc");
       if(myIndex < 0) {
         myIndex = name.indexOf(".xls");
       }
       if(myIndex < 0) {
         myIndex = name.indexOf(".pdf");
       }
       if(myIndex > 0) {
         isContinue = false;
         alert("File upload only accepts simple text formats.  Word Doc, Excel, and PDF formats are not supported.");
       }
    } else {
      isContinue = false;
      alert("Please select a file to load in Step #4.");
    }
    return isContinue;
  }
 
.....
 
Enter Email Address:

<INPUT size=25 name=email>


Select File To Upload:

<INPUT type=file name=fileName>

</TD></TR></TBODY></TABLE>

How could I "push" the filename to upload into this form? (I have NOT tried sendkeys,due to reliability issues)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,539
Messages
6,120,100
Members
448,944
Latest member
SarahSomethingExcel100

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top