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
1
u/TheFotty Aug 23 '24
The writing is on the wall that most things from MS directly are moving to a 'web app' model as browsers get more powerful and more and more things get integrated into subscriptions and perpetual online services. Just look at the hot garbage that is "new outlook" that they are pushing now. It may be an upgrade over the terrible mail client that has been shipping with windows, but it isn't even close to having feature parity with traditional outlook, yet they have already indicated this will replace outlook in a few years. All office apps will likely go the same route, since this means MS can offer these apps across windows,linux,mac and not have to really do much differnet to get them there.
I use webview2 even in Windows Forms .NET applications that need to be able to display web content. I have a project I maintain for a company that makes very heavy use of google maps and point plotting, and it was horrible when we were using the old browser control, but since moving to webview2, it is so much better performance wise and we got rid of a lot of shims we were using to make things work right with IE11's limited abilities for modern rendering and JS support.
Windows isn't going anywhere, but I think MS has shifted priorities to its subscriptions and services more so than the Windows OS.