title: How can I pass variable parameters into a Javascript Function using Excel VBA
body: <p>I'm not sure if I have the correct terms above, but what I'm trying to do is call a Javascript function passing parameters into it from an Excel File, so the function will run and list the items in the next textbox, allowing me to choose the correct entry in that textbox, which then chooses the final box.</p>
  
  <p>Here is the code that I have, that works, if I don't put variable into it:
  <code>Call .Document.parentWindow.execScript("FillVendorNames('MyText')", "javascript")</code>
  If I put in any variable in instead of 'MyText', I get a run time error:
  <code>Call .Document.parentWindow.execScript("FillVendorNames(cCode)", "javascript")
  Call .Document.parentWindow.execScript("FillVendorNames(.document.all.ComCode)", "javascript")</code>
  The variables are declared earlier in the code and I can check to see if the values are correct using the immediates window and they are all correct, but I still get the runtime error.</p>
  
  <p>What I'm trying to do is use the existing function which autofills a dropdown list, based on the option chosen in the original dropdown list.
  If I choose MyText in the first dropdown, then FillVendorNames gives the list of vendors in the next dropdown, allowing me to choose it.
  I can then enter the next choice in the next function and it picks a third option, but this is all based on the first function creating the second drop down list.
  The first list is autoloaded on the page, but the second isn't, so I can't choose an option from it.
  Can anyone help, please?
  Thanks.</p>