Sub Collector_Proc()
'Variable Declaration
Dim IE As Object
Dim AJ As String
Dim K As String
Dim rl As String
Dim w As Object
'Set iePopup = CreateObject("InternetExplorer.application")
Dim shell As ShellWindows
'Variable Initialization
Set shell = New ShellWindows
Set IE = CreateObject("InternetExplorer.application")
Set sh = ThisWorkbook.Sheets("Collector")
Set CR = ThisWorkbook.Sheets("Credentials")
'URL capture and Navigation
AJ = CR.Range("B5").Value
IE.navigate AJ
IE.Visible = True
'IE processing wait logic
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'Credentials Passing and processing
IE.document.getelementbyid("userid").Focus
IE.document.getelementbyid("userid").Value = ""
IE.document.getelementbyid("userid").Value = CR.Cells(1, 2).Value
IE.document.getelementbyid("pwd").Focus
IE.document.getelementbyid("pwd").Value = CR.Cells(2, 2).Value
Set tags = IE.document.getElementsByTagName("input")
For Each tagx In tags
If tagx.Value = "Sign In" Then
tagx.Click
Exit For
End If
Next
'IE processing wait logic
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'Calculation of number of UserID's to process
sh.Cells(2, 6).Value = sh.UsedRange.Rows.Count - 1
'Loop for each user ID
For i = 2 To sh.UsedRange.Rows.Count
If sh.Cells(i, 1).Value <> "" Then
If sh.Cells(i, 2).Value <> "Complete" Then
Set varitm = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.getelementbyid("OPRID_VW_OPRID")
varitm.Focus
varitm.Value = ""
varitm.Value = sh.Cells(i, 1).Value
Set varitm1 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.getelementbyid("#ICSearch")
varitm1.Focus
varitm1.Click
'IE processing wait logic
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'Selecting GL Link
Set varitm2 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_LINKS_OPR_DEF_LINK_GL1")
varitm2.Focus
varitm2.Click
'IE processing wait logic
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
' Re-setting up GL configuration
Set varitm3 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_FS_LEDGER")
varitm3.Focus
varitm3.Value = ""
Set varitm4 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_FS_LEDGER_GROUP")
varitm4.Focus
varitm4.Value = ""
Set varitm5 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_FS_SOURCE")
varitm5.Focus
varitm5.Value = ""
Set varitm6 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_GL_COPY")
varitm6.Focus
varitm6.Click
Set varitm7 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_GL_DELETE_CONTROL")
varitm7.Focus
varitm7.Click
Set varitm8 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_GL_UNPOST_FLG")
varitm8.Focus
varitm8.Click
Set varitm9 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_GL_SKIP_SUMLED_UPD_SW")
varitm9.Focus
varitm9.Click
Set varitm10 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_GL_SKIP_ESSBASE_LOAD")
varitm10.Focus
varitm10.Click
'Return to main Tab
Set varitm10 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("ICTAB_0")
varitm10.Focus
varitm10.Click
'IE processing wait logic
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'Selecting Procurement Link
Set varitm11 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_LINKS_OPR_DEF_LINK_PM1")
varitm11.Focus
varitm11.Click
'IE processing wait logic
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'clicking Sub-Procurement Link---Open POPUP Window
Set varitm12 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_PM_WRK_OPR_DEF_APVCHR_PB")
varitm12.Focus
varitm12.Click
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'Debug.Print IE.LocationName, IE.LocationURL, IE.AddressBar, IE.Application
' For Each IE In shell
'Print URL for Each Window but only one URL is getting printed as POPUP window dont have URL associated, it is getting open from DO-Modal
'sh.Cells(i + 7, 5).Value = IE.LocationURL
'Exit For
'Next
For Each w In CreateObject("Shell.Application").Windows
If w.Name Like "*Internet Explorer" Then
Debug.Print w.LocationURL
End If
Next
'sh.Cells(10, 5).Value = IE.LocationName
'sh.Cells(11, 5).Value = IE.LocationURL
'sh.Cells(12, 5).Value = IE.AddressBar
'sh.Cells(13, 5).Value = IE.Application
'Set varitm13 = IE.document.getElementById("ptifrmtgtframe").contentWindow.document.all.Item("OPR_DEF_TBL_AP_PYMNT_RCRD_FLG")
'Set varitm13 = IE.document.getelementbyid("pt_modals").getelementbyid("ptMod_0").getelementbyid("ptModTable_0").getelementbyid("ptModContent_0").getelementbyid("ptModFrame_0").getelementbyid("OPR_DEFAULT").getelementbyid("win0divPAGECONTAINER").getelementbyid("win0divPSPAGECONTAINER").getelementbyid("ACE_width").getelementbyid("win0divOPR_DEF_TBL_AP_AUTH_APPROVE_VCHR").getelementbyid("ACE_OPR_DEF_TBL_AP_AUTH_APPROVE_VCHR").getelementbyid("win0divOPR_DEF_TBL_AP_ORIGIN").getelementbyid("OPR_DEF_TBL_AP_ORIGIN")
'If iePopup Is Nothing Then
'Set iePopup = GetInstance(TimeOutInSeconds:=5, _
'URL:="11http://www.dowjones.com/DJCom/Images/ContentImages/TheCompany/virtuouscircle.jpg")
'End If
' varitm13.Focus
' varitm13.Click
Set varitm13 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.all.Item("#ICSave")
varitm13.Focus
varitm13.Click
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
Set varitm14 = IE.document.getelementbyid("ptifrmtgtframe").contentWindow.document.getelementbyid("#ICList")
varitm14.Focus
varitm14.Click
Application.Wait (Now + TimeValue("00:00:03"))
While IE.Busy = True
DoEvents
Wend
With IE
Do Until .readyState = 4: DoEvents: Loop
End With
'IE.Navigate "https://fms-dev.intertek.com/psp/FINDEV1/EMPLOYEE/ERP/c/MAINTAIN_SECURITY.USERMAINT.GBL?FolderPath=PORTAL_ROOT_OBJECT.PT_PEOPLETOOLS.PT_SECURITY.PT_USER_PROFILES.PT_USERMAINT_GBL&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder"
sh.Cells(i, 2).Value = "Complete"
End If
End If
Next i
End Sub