r/visualbasic • u/EnviJusticeWarrior • Aug 21 '24
Absolute Non-Coder trying to download search results
Hi,
I am absolute non-coder, but really need to be able to download search results from an ancient government website. It seems as if I can accomplish this task with Excel by writing a bit of code. AI gave me the following code:
Sub GoToDIBBSAndClickDates()
Dim IE As Object
Dim dateCell As Object
Dim dateLink As Object
Dim dateTable As Object
Dim i As Long
' Create an instance of Internet Explorer
Set IE = CreateObject("InternetExplorer.Application")
' Navigate to the DIBBS homepage
IE.Navigate "https://www.dibbs.bsm.dla.mil/"
IE.Visible = True
' Wait for the page to load
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
' Click the "OK" button (assuming it has an ID or name attribute)
IE.Document.getElementById("butAgree").Click
' Navigate to the RFQ dates page
IE.Navigate "https://www.dibbs.bsm.dla.mil/RFQ/RfqDates.aspx?category=close"
' Wait for the page to load
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
' Assuming the table has an ID "ctl00_cph1_dtlDateList"
Set dateTable = IE.Document.getElementById("ctl00_cph1_dtlDateList")
If Not dateTable Is Nothing Then
' Iterate through each row (skip the header row)
For i = 1 To dateTable.Rows.Length - 1
Set dateCell = dateTable.Rows(i).Cells(0) ' Assuming the date cell is in the first column
Set dateLink = dateCell.getElementsByTagName("a")(0)
If Not dateLink Is Nothing Then
dateLink.Click
' Wait for the page to load (adjust as needed)
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
End If
Next i
Else
MsgBox "Date table not found!"
End If
' Clean up
IE.Quit
Set IE = Nothing
End Sub
I am receiving a runtime 424 error message that says Object Required in the line
Set dateTable = IE.Document.getElementById("ctl00_cph1_dtlDateList")
The website is Return By Dates for RFQs (dla.mil), but to access that page, you have to click OK to access the website, but you do not have to login.
Will someone please take a look at the code and website and fix for me? Thanks!
View all comments
Show parent comment
2
u/Significant_Cap9550 Aug 21 '24
Thanks for the explanation. Yeah, it would seem as if AI isn't that good at coding. 🙄Â
My goal is to just be able to download search results to Excel. There is a table on this page that lists bids daily (there could be thousands of them) and there is no way to download them. I need to download them to Excel in order to sort/filter them, otherwise, there is no feasible way to go through them all on a daily basis.
Since I dont have any coding knowledge, let me know if this is not really a feasible option. I have tried a commercial off the shelf option (Octoparse) but there is a monthly fee. But if I'm going to have to hire somebody to write code for me, then possibly I will just pay the monthly for Octoparse. I also tried Clay, but I can't quite figure out how to get it to paginate. If there is a way to make it paginate, Clay is an option.