Hi,
I have excel macro containing vba codes which navigates to a URL and data from excel file is copied to text boxes in webpage.
on submission, result is generated on webpage. The code is mentioned below
Dim IE As Object
Dim Inputfile_Client As Workbook
Dim cl, rw As Integer
Dim ocl, orw As Integer
Dim icl, irw As Integer
Dim i As Integer
Dim j As Integer
Dim Max_rw As Integer
Dim Max_cl As Integer
Dim sh_rw As Integer
Private Sub CommandButton1_Click()
Dim iLastRow As Integer
Dim shNameClient As String
Set Inputfile_Client = ThisWorkbook
Inputfile_Client.Activate
Max_rw = 2
''Max_cl = 2
Inputfile_Client.Sheets(1).Activate
shNameClient = ActiveSheet.Name
Do While Inputfile_Client.Sheets(shNameClient).Cells(Max_rw, 1) <> ""
Call CopyDataFromExcelToWebPage(shNameClient, Max_rw)
Max_rw = Max_rw + 1
Loop
sh_rw = Max_rw - 1
End Sub
Sub CopyDataFromExcelToWebPage(shName As String, rw As Integer)
Application.ScreenUpdating = False
Dim xOffset As Integer
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate CStr(Inputfile_Client.Sheets(shName).Cells(4, 18))
Application.StatusBar = "Submitting"
' Wait while IE loading...
'While IE.Busy
' DoEvents
'Wend
' **********************************************************************
delay 2
xOffset = SetSelect(IE.document.All.Item("WccUnitCtrl_wddlDistrict"), Inputfile_Client.Sheets(shName).Cells(rw, 7))
IE.document.getElementById("WccUnitCtrl_wddlDistrict").selectedindex = xOffset
delay 2
xOffset = SetSelect(IE.document.All.Item("WccUnitCtrl_wddlUnitType"), Inputfile_Client.Sheets(shName).Cells(rw, 8))
IE.document.getElementById("WccUnitCtrl_wddlUnitType").selectedindex = xOffset
delay 2
xOffset = SetSelect(IE.document.All.Item("WccUnitCtrl_wddlUnit"), Inputfile_Client.Sheets(shName).Cells(rw, 9))
IE.document.getElementById("WccUnitCtrl_wddlUnit").selectedindex = xOffset
delay 2
IE.document.getElementById("wtxtName").Value = Inputfile_Client.Sheets(shName).Cells(rw, 1)
delay 2
IE.document.getElementById("wtxtFatherName").Value = Inputfile_Client.Sheets(shName).Cells(rw, 2)
delay 2
IE.document.getElementById("wtxtHusbandName").Value = Inputfile_Client.Sheets(shName).Cells(rw, 3)
delay 2
xOffset = SetSelect(IE.document.All.Item("wddlSex"), Inputfile_Client.Sheets(shName).Cells(rw, 4))
IE.document.getElementById("wddlSex").selectedindex = xOffset
delay 2
IE.document.getElementById("wtxtHeight1").Value = Inputfile_Client.Sheets(shName).Cells(rw, 5)
delay 2
IE.document.getElementById("wtxtAgeRange1").Value = Inputfile_Client.Sheets(shName).Cells(rw, 6)
delay 2
xOffset = SetSelect(IE.document.All.Item("wddlMethods"), Inputfile_Client.Sheets(shName).Cells(rw, 10))
IE.document.getElementById("wddlMethods").selectedindex = xOffset
delay 2
If Inputfile_Client.Sheets(shName).Cells(rw, 14) = "Exact Match" Then
IE.document.All("Match").Item(0).Checked = True
Else
IE.document.All("Match").Item(1).Checked = True
End If
delay 2
'xOffset = SetSelect(IE.Document.All.Item("wdlMajorHeads_ctl04"), Inputfile_Client.Sheets(shName).Cells(rw, 15))
'IE.Document.getElementById("wdlMajorHeads_ctl04").selectedindex = xOffset
'IE.Document.getElementById("wdlMajorHeads_ctl04").Value = Inputfile_Client.Sheets(shName).Cells(rw, 15)
delay 2
xOffset = SetSelect(IE.document.All.Item("wddlMotives"), Inputfile_Client.Sheets(shName).Cells(rw, 11))
IE.document.getElementById("wddlMotives").selectedindex = xOffset
delay 2
IE.document.getElementById("wtxtFirFrom").Value = Format(Inputfile_Client.Sheets(shName).Cells(rw, 12), "dd/mm/yyyy")
delay 2
IE.document.getElementById("wtxtFirTo").Value = Format(Inputfile_Client.Sheets(shName).Cells(rw, 13), "dd/mm/yyyy")
delay 2
'IE.Document.getElementById("wbtnSearch").Click
'IE.Document.forms(0).submit
'Dim objCollection As Object
'Dim objElement As Object
'Set objCollection = IE.document.getElementsByTagName("input")
'i = 0
'While i < objCollection.Length
' If objCollection(i).Type = "submit" And objCollection(i).Name = "wbtnSearch" Then ' submit button if found and set
' Set objElement = objCollection(i)
' End If
'i = i + 1
'Wend
'objElement.Click ' click button to load page
'Do While IE.ReadyState <> 4
' DoEvents
'Loop
'Application.SendKeys "%{S}"
'**********************************************************************
Application.StatusBar = "Form Submitted"
'IE.Quit
'Set IE = Nothing
Application.ScreenUpdating = True
End Sub
Private Sub delay(seconds As Long)
Dim endTime As Date
endTime = DateAdd("s", seconds, Now())
Do While Now() < endTime
DoEvents
Loop
End Sub
Function SetSelect(xComboName, xComboValue) As Integer
'Finds an option in a combobox and selects it.
Dim x As Integer
For x = 0 To xComboName.Options.Length - 1
If xComboName.Options(x).Text = xComboValue Then
xComboName.selectedindex = x
Exit For
End If
Next x
SetSelect = x
End Function
In the above code, i need addition of codes to download all the generated active webpages in perticular folder.
thanks in advance
Bookmarks