vvSTRIDEvv
12-20-2010, 08:04 AM
I'm currently working to automate some reporting functions. The goal is to have a report which is normally manual. Populate with data stored on our company extranet website.
There is a section of the site where the user can export reports based on (Location, Department, Date).
So far I've figured out the ID's and code for most of the page. However, I'm hitting a wall. Once the criteria is entered the user must click on a link "Export". I can't seem to code VB to click this link.
Here is some of the code...link error at the bottom:
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate ("://website")
While .Busy Or .readyState <> 4: DoEvents: Wend
.document.getelementbyid("ctl00_cphMain_ctrlLogin_user_new").Focus
.document.getelementbyid("ctl00_cphMain_ctrlLogin_user_new").Value = "name"
.document.getelementbyid("ctl00_cphMain_ctrlLogin_pw_new").Focus
.document.getelementbyid("ctl00_cphMain_ctrlLogin_pw_new").Value = "password"
.document.all("ctl00_cphMain_ctrlLogin_btnLogin_new").Click
While .Busy Or .readyState <> 4: DoEvents: Wend
Debug.Print .LocationURL
End With
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
.navigate ("//website")
While .Busy Or .readyState <> 4: DoEvents: Wend
.document.getelementbyid("ctl00_cphMain_Label1").Focus
.document.all("ctl00_cphMain_Label1").Click
.document.getelementbyid("ctl00_cphMain_Label2").Focus
.document.getelementbyid("ctl00_cphMain_lbDepartment").Value = "284"
.document.getelementbyid("ctl00_cphMain_Label3").Focus
.document.getelementbyid("ctl00_cphMain_txbFromDate").Value = "12-08-2010"
.document.all("ctl00_cphMain_btnRender").Click
End With
With IE
While .Busy Or .readyState <> 4: DoEvents: Wend
Debug.Print .LocationURL
.document.getelementbyid("ctl00_cphMain_rptView_ctl01_ctl05_ctl00").Focus
.document.all("ctl00_cphMain_rptView_ctl01_ctl05_ctl00").Click
.document.getelementbyid("ctl00_cphMain_rptView_ctl01_ctl05_ctl00").Value = "EXCEL"
.document.all("ReportFramectl00_cphMain_rptView").Click
.document.all("oReportDiv").Click
End With
I've also attached the source, and help would be HUGE!!!
There is a section of the site where the user can export reports based on (Location, Department, Date).
So far I've figured out the ID's and code for most of the page. However, I'm hitting a wall. Once the criteria is entered the user must click on a link "Export". I can't seem to code VB to click this link.
Here is some of the code...link error at the bottom:
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate ("://website")
While .Busy Or .readyState <> 4: DoEvents: Wend
.document.getelementbyid("ctl00_cphMain_ctrlLogin_user_new").Focus
.document.getelementbyid("ctl00_cphMain_ctrlLogin_user_new").Value = "name"
.document.getelementbyid("ctl00_cphMain_ctrlLogin_pw_new").Focus
.document.getelementbyid("ctl00_cphMain_ctrlLogin_pw_new").Value = "password"
.document.all("ctl00_cphMain_ctrlLogin_btnLogin_new").Click
While .Busy Or .readyState <> 4: DoEvents: Wend
Debug.Print .LocationURL
End With
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
.navigate ("//website")
While .Busy Or .readyState <> 4: DoEvents: Wend
.document.getelementbyid("ctl00_cphMain_Label1").Focus
.document.all("ctl00_cphMain_Label1").Click
.document.getelementbyid("ctl00_cphMain_Label2").Focus
.document.getelementbyid("ctl00_cphMain_lbDepartment").Value = "284"
.document.getelementbyid("ctl00_cphMain_Label3").Focus
.document.getelementbyid("ctl00_cphMain_txbFromDate").Value = "12-08-2010"
.document.all("ctl00_cphMain_btnRender").Click
End With
With IE
While .Busy Or .readyState <> 4: DoEvents: Wend
Debug.Print .LocationURL
.document.getelementbyid("ctl00_cphMain_rptView_ctl01_ctl05_ctl00").Focus
.document.all("ctl00_cphMain_rptView_ctl01_ctl05_ctl00").Click
.document.getelementbyid("ctl00_cphMain_rptView_ctl01_ctl05_ctl00").Value = "EXCEL"
.document.all("ReportFramectl00_cphMain_rptView").Click
.document.all("oReportDiv").Click
End With
I've also attached the source, and help would be HUGE!!!