kbay808
asked on
How to add a wildcard to a URL in VBA?
In the code below, I have multiple versions of the same URL. I would like to change it to something like this with a wildcard. "https://servman/sm/index.do*"
Sub getIE(ByRef objIE As Object, ByRef blnFoundWebSite As Boolean)
On Error GoTo ErrorRoutine
Dim strURL As Variant
Dim strURLs As String
Dim objShell As SHDocVw.ShellWindows
Dim objIEDOC As Object
Set objShell = New SHDocVw.ShellWindows
' **** Set the Web Address Here ****
strURLs = "https://servman/sm/index.do,https://servman/sm/index.do#,https://servman/sm/index.do?lang=en,https://servman/sm/index.do?lang=en&mode=index.do,https://servman/sm/index.do?lang=en&mode=index.do&logout_msg=LogoutPage.session_timeout"
' Look for the appropriate open IE Window
For Each objIE In objShell
If TypeOf objIE.Document Is MSHTML.HTMLDocument Then
Set objIEDOC = objIE.Document
If Not (objIEDOC Is Nothing) Then
For Each strURL In Split(strURLs, ",")
If objIEDOC.URL = strURL Then
blnFoundWebSite = True
Exit For
End If
Next
If blnFoundWebSite = True Then Exit For
End If
End If
Next
On Error Resume Next
Set objIE = objIE
Set objIE = objIE.frames.Item(0)
Set objIE = objIE.frames.Item(1)
On Error GoTo 0
Set objShell = Nothing
Set objIEDOC = Nothing
Exit Sub
ErrorRoutine:
End Sub
ASKER
All of the URLs start with "https://servman/sm/index.do". It doesn't matter what comes after it.
You can't use a wildcard in a URL to navigate to a site.
Do you have a list of possible values, or perhaps some sort of string pattern that could come after the 'base' URL https://servman/sm/index.do?
What do you see if you navigate to https://servman/sm/index.do?
Do you have a list of possible values, or perhaps some sort of string pattern that could come after the 'base' URL https://servman/sm/index.do?
What do you see if you navigate to https://servman/sm/index.do?
ASKER
ASKER
Just to clarify, the code does not open the URL. It's just searching IE for one that is already open.
Hmm, having a code that open the same web page with various parameters at the same time.... suspicious if you ask me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's not opening it. The web page is already open. I just need to target it to click buttons and input data.
ASKER
That worked perfect!!! Thanks
Replace it with various values ?
If so, it is better to have a base URL (constant if possible), and concatenate the different values later.