<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: How to automate a dynamic web page using VBA?</title>
	<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA/</link>
	<description>Comments on Ask MetaFilter post How to automate a dynamic web page using VBA?</description>
	<pubDate>Wed, 09 May 2012 10:32:08 -0800</pubDate>
	<lastBuildDate>Wed, 09 May 2012 10:49:59 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: How to automate a dynamic web page using VBA?</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA</link>	
		<description>Help me automate some of my work involving taking values in a spreadsheet and plugging them into a website with dynamically generated content. &lt;br /&gt;&lt;br /&gt; I need someone to point me in the right direction. I have several tasks which are very mechanical which I would like to automate. One, for instance, involves taking a list of product numbers from a spreadsheet, entering them one at a time to a website, then printing the resulting page. &lt;br&gt;
&lt;br&gt;
I have tried to automate this via VBA, and I can get as far as loading the page and entering the product number into the correct form field, but there is actually a step before this where a drop down needs to be selected before the product number field is active. I am actually able to set the value of this drop down, but doing this doesn&apos;t cause the page&apos;s javascript to enable the product number field and product number submit button which then ignores my attempt to programatically click it.&lt;br&gt;
&lt;br&gt;
Basically the page I want to use is dynamically generated, but the parts I want don&apos;t show up until after the necessary info has been entered, and I can&apos;t get the page to recognize that I&apos;ve automatically entered it. Further complicating the situation is that the web page I&apos;m working with is generated by ASP (I think) which I&apos;m not familiar with and which is inserting a lot of strange script tags with long strings of encoded data.&lt;br&gt;
&lt;br&gt;
Any help or pointers in the right direction would be greatly appreciated.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2012:site.214902</guid>
		<pubDate>Wed, 09 May 2012 10:32:08 -0800</pubDate>
		<dc:creator>Reverend John</dc:creator>
		
			<category>webpage</category>
		
			<category>automation</category>
		
			<category>vba</category>
		
			<category>ajax</category>
		
	</item>
	<item>
		<title>By: Dano St</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA#3101338</link>	
		<description>I point you in the following direction but can&apos;t say if it is the right one or not: don&apos;t worry so much about the page with the form as the one that processes it.  Look at the action of the &amp;lt;form&amp;gt; element and the names of the &amp;lt;input&amp;gt; elements and send an http POST request directly to that action with values for the names.  In other words, skip the step where a bunch of javascript creates the product number field altogether; just figure out what that field is called and populate it with a value.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2012:site.214902-3101338</guid>
		<pubDate>Wed, 09 May 2012 10:49:59 -0800</pubDate>
		<dc:creator>Dano St</dc:creator>
	</item><item>
		<title>By: ob1quixote</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA#3101339</link>	
		<description>If you can tease out the name of the function that picking a drop-down option invokes to enable the product number and submit button, you could do something like &lt;br&gt;
&lt;blockquote&gt;&lt;pre&gt;IE.document.all.Item &lt;br&gt;
Call IE.document.parentWindow.execScript(&quot;&lt;i&gt;&amp;lt;Name of Drop-down function&amp;gt;&lt;/i&gt;&quot;, &quot;JavaScript&quot;) &lt;/pre&gt;&lt;/blockquote&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2012:site.214902-3101339</guid>
		<pubDate>Wed, 09 May 2012 10:50:03 -0800</pubDate>
		<dc:creator>ob1quixote</dc:creator>
	</item><item>
		<title>By: Reverend John</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA#3101341</link>	
		<description>For what it&apos;s worth, here&apos;s my code:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
Sub PrintAttributeSheet()&lt;br&gt;
&apos;&lt;br&gt;
&apos; PrintAttributeSheet&lt;br&gt;
&apos; print attribute sheets&lt;br&gt;
&apos;&lt;br&gt;
&apos; Reverend John 20120416&lt;br&gt;
&apos;&lt;br&gt;
&lt;br&gt;
Dim myRange As Range&lt;br&gt;
Dim sku As String&lt;br&gt;
Dim myBrowswer As SHDocVw.InternetExplorer&lt;br&gt;
Dim supplierEl As Object&lt;br&gt;
Dim skuEl As Object&lt;br&gt;
Dim goEl As Object&lt;br&gt;
Dim printEl As Object&lt;br&gt;
&lt;br&gt;
Set myRange = ActiveWindow.RangeSelection&lt;br&gt;
&lt;br&gt;
sku = myRange.Value&lt;br&gt;
&lt;br&gt;
Set mybrowser = New SHDocVw.InternetExplorer&lt;br&gt;
&lt;br&gt;
mybrowser.Visible = True&lt;br&gt;
mybrowser.Navigate &quot;http://example.com/Product.aspx&quot;&lt;br&gt;
&lt;br&gt;
Do While mybrowser.Busy&lt;br&gt;
Loop&lt;br&gt;
&lt;br&gt;
Set supplierEl = mybrowser.Document.getelementbyid(&quot;ctl00_content_SupplierDropDown&quot;)&lt;br&gt;
supplierEl.Value = &quot;700&quot;&lt;br&gt;
&lt;br&gt;
Do While mybrowser.Busy&lt;br&gt;
Loop&lt;br&gt;
&lt;br&gt;
Set skuEl = mybrowser.Document.getelementbyid(&quot;ctl00_content_txtbxSrchItem&quot;)&lt;br&gt;
skuEl.Value = sku&lt;br&gt;
&lt;br&gt;
Do While mybrowser.Busy&lt;br&gt;
Loop&lt;br&gt;
&lt;br&gt;
Set goEl = mybrowser.Document.getelementbyid(&quot;ctl00_content_btnsrch&quot;)&lt;br&gt;
goEl.Click&lt;br&gt;
&lt;br&gt;
End Sub&lt;br&gt;
&lt;/pre&gt;&lt;br&gt;
&lt;br&gt;
The code was adapted from various website examples.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2012:site.214902-3101341</guid>
		<pubDate>Wed, 09 May 2012 10:50:08 -0800</pubDate>
		<dc:creator>Reverend John</dc:creator>
	</item><item>
		<title>By: burnmp3s</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA#3101438</link>	
		<description>If you don&apos;t end up getting the IE automation through VBA working there are other screen scraping methods/libraries you can try.  I tend to use &lt;a href=&quot;http://wwwsearch.sourceforge.net/mechanize/&quot;&gt;Mechanize&lt;/a&gt; for Python to automate browser stuff (and &lt;a href=&quot;http://www.crummy.com/software/BeautifulSoup/&quot;&gt;BeautifulSoup&lt;/a&gt; for parsing if necessary).  Mechanize doesn&apos;t actually use a real browser and doesn&apos;t support javascript, but in most cases I can figure out what the javascript is doing and simulate it (as Dano St mentioned for forms specifically you can save a lot of headaches by just sending the POST request directly with the correct data fields included).  If you do need actual browser automation there&apos;s also &lt;a href=&quot;http://seleniumhq.org/&quot;&gt;Selenium&lt;/a&gt;, although I haven&apos;t used it myself.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2012:site.214902-3101438</guid>
		<pubDate>Wed, 09 May 2012 11:48:20 -0800</pubDate>
		<dc:creator>burnmp3s</dc:creator>
	</item><item>
		<title>By: burnmp3s</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA#3101464</link>	
		<description>Also if it&apos;s not obvious what exact requests are being sent from the browser you can install a sniffer like &lt;a href=&quot;http://www.fiddler2.com/fiddler2/&quot;&gt;Fiddler&lt;/a&gt; and look at the traffic directly.  Generally no matter how convoluted the javascript on the page is, it usually ends up resulting in relatively simple POST data in the end.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2012:site.214902-3101464</guid>
		<pubDate>Wed, 09 May 2012 12:04:46 -0800</pubDate>
		<dc:creator>burnmp3s</dc:creator>
	</item><item>
		<title>By: Boobus Tuber</title>
		<link>http://ask.metafilter.com/214902/How-to-automate-a-dynamic-web-page-using-VBA#3105860</link>	
		<description>Maybe try using IE as a COM object, not the ShDocvw option? This creates a full instance of IE, rather than the stripped down version used in controls, web queries etc?&lt;br&gt;
&lt;br&gt;
e.g.&lt;a href=&quot;http://www.excely.com/excel-vba/ie-automation.shtml&quot;&gt; http://www.excely.com/excel-vba/ie-automation.shtml&lt;/a&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2012:site.214902-3105860</guid>
		<pubDate>Sun, 13 May 2012 11:54:14 -0800</pubDate>
		<dc:creator>Boobus Tuber</dc:creator>
	</item>
	</channel>
</rss>
