添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

So as i am opposed to the same kind of problem i'll try to submit you guys my case.

I am trying to automate datas extraction from valeo's catalogue using excel vba macro.

I have a list of références attached to valeo's automotive products (huge list, as more than 3000 thousands items). And i would like to import directly informations from the catalogue wich seems to run under javascript.

The datas i need is the list of every vehicules attached to a reference.

Here is the url: http://outcat-cs.tecdoc.net/ows/en/7FA2A0C501BC34CA4BECB04095663CF1.ows_cs2.srv?view=VIndexFramesetJsp

I'd like to access to the "Direct Article Search" tab, in order to copy a reference directly from an excel tab's cell and then simulate a clic on the reference in order to display the "linked vehicules section" and then to copy them in a new excel sheet.

I already succeede in doing this with html pure programmed webpage (oscaro.com) using the following code :

Set maPageHtml = IE.document
Set Helem = maPageHtml.getElementsByTagName("input")
For i = 0 To Helem.Length - 1 
    If Helem(i).getAttribute("name") = "toFind" Then Helem(i).Value = "819971" '819971 is the valeo reference searched
    If Helem(i).getAttribute("name") = "submit" Then Set Monbouton = Helem(i)
Monbouton.Click 'this does the click on my button Monbouton

But this technique can't be used with valeo website since I am not able (or at least I don't know yet how to do it) to select/click a button when the page is made on javascript, since it doesn't have a name, value or id for the button.

Also it seems that the url in the address field is the same before clicking on the "Direct Article Search" button and after having clicked....

Hope i am clear enought in spite of my english...

Greetings

I don't think that there is a direct way to run JavaScript code in VBA.

What you could try to do is to embed the JavaScript code in an HTML form which you could open in a (hidden) browser control. Then fill the form controls via the DOM of the browser control and submit the form. The submit triggers the JavaScript function that you want to call.

Sample (not tested):

oIE.Document.frmMain.param1.Value = 5
oIE.Document.frmMain.param2.Value = "6"
oIE.Document.frmMain.submit.click ' this line will call the JavaScript function

HTML:

<div id="submit" > <a href="javascript:doAction();">Do Action</a></div>
<script>
function doAction()
    // do whatever the code should do
</script>

You mean through windows scripting host? You can shell (use the shell command) out to wscript.exe with the name of the .js file. But this javascript object model won't be like the one you get in the browser. It would be helpful if you told us what the javascript was supposed to do.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.