Hi,
I have a web page with multiple dynamic hrefs, everyone associated with specific data. I have to click on one of these based on related data.
To do that, I have temporarily exported to excel the href list with related data as a support to choose the correct one.
The website does not accept an external connection request, so I cannot click on the link created in Excel but I do need to click on href from within the web page.
So, I thought to assign the href innerHTML content to a string variable and use it to find and click on the href.
The question is, it is possibile to use variables with queryselector?
This is the relevant piece of code:
I've found that in javascript it is possibile to do something like this:
var name = "hello, world!";
document.querySelector("[data-name=" + CSS.escape(name) + "]");
but CSS.escape it is not allowed in vba. How can I solve it?
Any suggestion is appreciated.
I have a web page with multiple dynamic hrefs, everyone associated with specific data. I have to click on one of these based on related data.
To do that, I have temporarily exported to excel the href list with related data as a support to choose the correct one.
The website does not accept an external connection request, so I cannot click on the link created in Excel but I do need to click on href from within the web page.
So, I thought to assign the href innerHTML content to a string variable and use it to find and click on the href.
The question is, it is possibile to use variables with queryselector?
This is the relevant piece of code:
VBA Code:
'this is the string where I stored the href content
hrefStr = CStr(ActiveWorkbook.Sheets("temp").Cells(m + 1, 6).Value)
'this doesn't work
IE.Document.querySelector("a[href=hrefStr").Click
'this doesn't work either
IE.Document.querySelector("a[href=" + (hrefStr) + "]").Click
'this doesn't work either
IE.Document.querySelector("a[href=" & hrefStr & "]").Click
I've found that in javascript it is possibile to do something like this:
var name = "hello, world!";
document.querySelector("[data-name=" + CSS.escape(name) + "]");
but CSS.escape it is not allowed in vba. How can I solve it?
Any suggestion is appreciated.