Copying columns of values from Excel worksheet to an HTML table in a website

 Question:

I'm hoping to copy values from an excel table into an html table. If anyone has experience doing this between Excel 2013 and Internet Explorer 11, please let me know and I can give details. Thank you
The following is a little section of the code for the website that I am trying to automate the fill-in process for:
Table and Source Code for Charge Numbers for the Site
This is showing just one part of the process (the charge numbers), which we have anywhere from 10-25 each week with their corresponding hours charged to them each day (as seen in the table matrix).
There are 7 charge numbers on each page and Charge Numbers all have name="chargeNo" and increase id names with each box downward like so:
'1) id="chargeNo0"  
'2) id="chargeNo1"  
'3) id="chargeNo2"  
'4) id="chargeNo3"  
'5) id="chargeNo4"  
'6) id="chargeNo5"  
'7) id="chargeNo6"  
Each day of the week also has set names as follows:
Table and Source Code for Hours Charged Each Day
'Saturday: name="hrs0"  
'Sunday: name="hrs1"  
'Monday: name="hrs2"  
'Tuesday: name="hrs3"  
'Wed: name="hrs4"  
'Thurs: name="hrs5"  
'Fri: name="hrs6"  
I'm trying to automate the process of pulling the arrays of charge times I have from Excel and inputting them into their respective textboxes.
 




 Answers: 

This script will convert elements in ColumnA into an array.
Sub MakeArray()
   Dim arr As Variant

   With ActiveSheet
      arr = WorksheetFunction.Transpose(.Range(.[A1], .Cells(Rows.Count, "A").End(xlUp)))
   End With
End Sub


Sub MakeString()
   Dim s As String

   Const DELIMITER = ","

   With ActiveSheet
      s = Join(WorksheetFunction.Transpose(.Range(.[A1], .Cells(Rows.Count, "A").End(xlUp))), DELIMITER)
   End With
End Sub
If you want to pass the array to an HTML TextBox, try this.
    Sub CreateArrayAndPassToHTMLTextbox()
       Dim ie  As Object
       Dim arr As Variant

       Const DELIMITER = ","

       Set ie = CreateObject("InternetExplorer.Application")

       ie.Visible = True
       ie.navigate "http://home.arcor.de/peter.schleif/SearchForTDelement.html"
       While ie.Busy: DoEvents: Wend

       With ActiveSheet
          arr = WorksheetFunction.Transpose(.Range(.[A1], .Cells(Rows.Count, "A").End(xlUp)))
          If Not IsArray(arr) Then arr = Array(arr)
          ie.document.getElementById("trackField").Value = Join(arr, DELIMITER)
       End With
    End Sub
If, for instance, you want to pass data to a ComboBox, try this.
Sub passValueToComboBox1()
   Dim ie  As Object
   Dim oHTML_Element As IHTMLElement

   Set ie = CreateObject("InternetExplorer.Application")
   ie.Visible = True
   ie.navigate "http://peterschleif.bplaced.net/excel/combobox/index.php"
   While ie.Busy Or ie.readyState <> 4: DoEvents: Wend

   Set oHTML_Element = ie.document.getElementsByName("selectedReportClass")(0)
   If Not oHTML_Element Is Nothing Then oHTML_Element.Value = "com.db.moap.report.FUBU7"

   For Each oHTML_Element In ie.document.getElementsByTagName("input")
      If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
   Next
End Sub

Commentaires

Posts les plus consultés de ce blog

XAJAX with PHP – The future of web development

XAJAX with PHP – The future of web development

Database connection pooling in ADO.Net