<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Automation Beyond &#187; How to</title>
	<atom:link href="http://automation-beyond.com/category/programming/code-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://automation-beyond.com</link>
	<description>An engineering approach to Software Testing and Test Automation</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:56:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>		<item>
		<title>How to select random list item (QTP, VBScript)</title>
		<link>http://automation-beyond.com/2011/11/24/how-to-select-random-list-item/</link>
		<comments>http://automation-beyond.com/2011/11/24/how-to-select-random-list-item/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 10:36:55 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[item]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[pick]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[rnd]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[WebList]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=4723</guid>
		<description><![CDATA[Description  Get object reference. Get total number of items in the list. Generate an index within the given range. Select item by index. Implementation Dim objPage, objList Dim boolRC Dim intItemsCount, intRndItem 'Assumptions: ' &#34;Google Advanced Search&#34; page is up ' &#34;Results per page&#34; WebList exists and enabled 'Get page object Set objPage = Browser(&#34;CreationTime:=0&#34;).Page(&#34;title:=Google Advanced Search&#34;) [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2011%252F11%252F24%252Fhow-to-select-random-list-item%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fu8ZG6A%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20select%20random%20list%20item%20%28QTP%2C%20VBScript%29%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>Description </h4>
<p>Get object reference. Get total number of items in the list. Generate an index within the given range. Select item by index.</p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">

Dim objPage, objList
Dim boolRC
Dim intItemsCount, intRndItem

'Assumptions:
' &quot;Google Advanced Search&quot; page is up
' &quot;Results per page&quot; WebList exists and enabled

'Get page object
Set objPage = Browser(&quot;CreationTime:=0&quot;).Page(&quot;title:=Google Advanced Search&quot;)
boolRC = objPage.Exist(0)
If Not boolRC Then
 ExitTest
End If

'Get list object
Set objList = objPage.WebList(&quot;name:=num&quot;)
boolRC = objList.Exist(0)
If Not boolRC Then
 ExitTest
End If

'Get number of list items
intItemsCount = objList.GetROProperty(&quot;items count&quot;)
'Create random index
Randomize
intRndItem = CInt(Rnd*intItemsCount)
'Select the item
'Note: selection by index is zero-based
objList.Select &quot;#&quot; &amp; intRndItem
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2007/12/23/custom-lists-winrunner/" rel="bookmark" class="crp_title">Custom lists: Select Multi / Select All with WinRunner</a></li><li><a href="http://automation-beyond.com/2007/11/15/test-log-messages/" rel="bookmark" class="crp_title">Test Log Messages</a></li><li><a href="http://automation-beyond.com/2011/07/19/xmlnode2dictionary/" rel="bookmark" class="crp_title">XMLNode2Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/09/23/gp-automation-vbscript-limitation/" rel="bookmark" class="crp_title">GP/QTP Automation: Overcoming VBScript limitation with Excel macros</a></li><li><a href="http://automation-beyond.com/2010/03/04/manually-get-dexterity-gui-field-names/" rel="bookmark" class="crp_title">How to manually get Dexterity GUI field names</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2011/11/24/how-to-select-random-list-item/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find last modified file (TestComplete, QTP, VBScript)</title>
		<link>http://automation-beyond.com/2011/07/26/how-to-find-last-modified-file/</link>
		<comments>http://automation-beyond.com/2011/07/26/how-to-find-last-modified-file/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 10:20:02 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[File System Operations]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[3. Automation]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[Attribute]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[DateCreated]]></category>
		<category><![CDATA[DateLastAccessed]]></category>
		<category><![CDATA[DateLastModified]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[filename unknown]]></category>
		<category><![CDATA[FileSystemObject]]></category>
		<category><![CDATA[FSO]]></category>
		<category><![CDATA[last]]></category>
		<category><![CDATA[modified]]></category>
		<category><![CDATA[most]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[property]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[recent]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=3759</guid>
		<description><![CDATA[Reference page: Service Functions – System (QTP, VBScript) Description  Check folder exists &#8211; check folder has files. Iterate through collection of files and keep reference of the most recently modified file (its DateLastModified property is always the highest number). The remaining reference is the one that you need. In case of errors the function returns [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2011%252F07%252F26%252Fhow-to-find-last-modified-file%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FnDgvOC%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20find%20last%20modified%20file%20%28TestComplete%2C%20QTP%2C%20VBScript%29%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>Reference page: <a title="Service Functions – System (QTP, VBScript)" href="http://automation-beyond.com/2009/12/05/service-functions-system/" target="_blank">Service Functions – System (QTP, VBScript)</a></p>
<h4>Description </h4>
<p>Check folder exists &#8211; check folder has files. Iterate through collection of files and keep reference of the most recently modified file (its <em>DateLastModified</em> property is always the highest number). The remaining reference is the one that you need. In case of errors the function returns <em>Nothing</em>. </p>
<p>Note. In some cases, you may want to use <em>DateCreated</em> or <em>DateLastAccessed</em> properties.</p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">

Public Function GetLastModifiedFile(ByVal sFolderPath)
  Dim FSO, objFolder, objFile
  Dim objFileResult, longDateTime
  Dim boolRC
 
  Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
  boolRC = FSO.FolderExists(sFolderPath)
  If Not boolRC Then
    Set FSO = Nothing
    Set GetLastModifiedFile = Nothing
    Exit Function
  End If

  Set objFolder = FSO.GetFolder(sFolderPath)
  If objFolder.Files.Count = 0 Then
    Set FSO = Nothing
    Set objFolder = Nothing
    Set GetLastModifiedFile = Nothing
    Exit Function
  End If
 
  Set objFileResult = Nothing
  longDateTime = CDate(0)
 
  For Each objFile in objFolder.Files
 
    If objFile.DateLastModified &gt; longDateTime Then
      Set objFileResult = objFile
      longDateTime = objFile.DateLastModified
    End If
   
  Next
 
  Set FSO = Nothing
  Set objFolder = Nothing
  Set GetLastModifiedFile = objFileResult

End Function
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2008/06/13/createxmldomfromfile/" rel="bookmark" class="crp_title">CreateXMLDOMFromFile (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/01/12/service-functions-excel/" rel="bookmark" class="crp_title">Service Functions – Excel (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2008/11/10/minor-major-defect/" rel="bookmark" class="crp_title">Minor defect as a symptom of a major defect</a></li><li><a href="http://automation-beyond.com/2008/06/30/service-functions-msxmldom/" rel="bookmark" class="crp_title">Service Functions &#8211; MSXMLDOM (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/11/10/testcomplete-find-child/" rel="bookmark" class="crp_title">TestComplete &#8211; Find Child or Find Yourself?</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2011/07/26/how-to-find-last-modified-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to &#8220;Save As&#8221; text template</title>
		<link>http://automation-beyond.com/2010/10/26/how-to-save-as/</link>
		<comments>http://automation-beyond.com/2010/10/26/how-to-save-as/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 12:23:09 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[Text Data]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[as]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[FileSystemObject]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[save as]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[testcomplete]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[use]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=3688</guid>
		<description><![CDATA[Parent page: Service Functions – System (QTP, VBScript) Question I need to modify text file template (add a few lines) and &#8220;Save as&#8221;. Answer One of the typical challenges that people face while trying to automate work tasks, is &#8220;procedure &#8211; result&#8221; confusion. Here, the end result* is confused with a way** to do the [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F10%252F26%252Fhow-to-save-as%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20%5C%22Save%20As%5C%22%20text%20template%22%20%7D);"></div>
<p>Parent page: <a title="Service Functions – System (QTP, VBScript)" href="http://automation-beyond.com/2009/12/05/service-functions-system/" target="_blank">Service Functions – System (QTP, VBScript)</a></p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h3>Question</h3>
<blockquote><p>I need to modify text file template (add a few lines) and &#8220;Save as&#8221;.</p></blockquote>
<h4>Answer</h4>
<p>One of the typical challenges that people face while trying to automate work tasks, is &#8220;procedure &#8211; result&#8221; confusion. Here, the end result* is confused with a way** to do the task.</p>
<h4>* What is wanted</h4>
<p>Text file with required contents is stored under defined name in required location.</p>
<h4>** How it&#8217;s done manually</h4>
<p>Open text file template in a text editor &#8211; add required text &#8211; save as new file (select path to store, type in new name).</p>
<h4>How to automate</h4>
<p>First of all, <a href="http://automation-beyond.com/2009/10/24/how-to-check-if-file-exists/" target="_blank">check</a> that file exists. Create a copy of the template file. If you are not sure that new name and/or location is valid, use <a href="http://automation-beyond.com/2008/12/04/winrunner2qtp-4/" target="_blank">error handling</a>. Open text file for appending and add required text. Close file to get it saved.</p>
<p>Note. Sample code below is equally suitable for QTP and TestComplete. </p>
<h4>Implementation</h4>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">

  Dim FSO
  Dim objFile, objTextStream
  Dim boolRC
 
  Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)

  Call FSO.CopyFile(&quot;C:\Temp\template.txt&quot;, &quot;C:\Temp\myblog.txt&quot;, True)   
  Set objTextStream = FSO.OpenTextFile(&quot;C:\Temp\myblog.txt&quot;, 8, True)
  objTextStream.WriteLine(&quot;http://automation-beyond.com/&quot;)
  objTextStream.Close()
 
  Set objTextStream = Nothing
  Set objFile = Nothing
  Set FSO = Nothing
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2009/12/05/service-functions-system/" rel="bookmark" class="crp_title">Service Functions – System (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/03/14/xsl-using-sub-templates/" rel="bookmark" class="crp_title">XML/XSL Transformation: Using Sub-Templates</a></li><li><a href="http://automation-beyond.com/2010/01/14/how-to-call-excel-function/" rel="bookmark" class="crp_title">How to call Excel VBA function from QTP</a></li><li><a href="http://automation-beyond.com/2010/04/13/ad-scripting-fail-safe-trick/" rel="bookmark" class="crp_title">Active Directory Scripting &#8211; a little trick for fail-safe automation</a></li><li><a href="http://automation-beyond.com/2011/05/25/xsl-using-styles/" rel="bookmark" class="crp_title">XML/XSL Transformation: Using Styles</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/10/26/how-to-save-as/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick questions &#8211; quick answers</title>
		<link>http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/</link>
		<comments>http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 13:00:50 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Notes]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[generic]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[Repository]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2862</guid>
		<description><![CDATA[Quick Answers Quick answers to questions arrived into my blog recently. How to load GUI map in QTP during run-time? Use methods of RepositoriesCollection object: Find / Add / Remove. See sample code, read investigation results. What&#8217;s the name of add-in for MS Dynamics Great Plains automation? There is no specific add-in. You would need Dot [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F06%252F22%252Fquick-questions-quick-answers%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FeatBA6%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Quick%20questions%20-%20quick%20answers%22%20%7D);"></div>
<h3>Quick Answers</h3>
<p>Quick answers to questions arrived into my blog recently.</p>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<h4>How to load GUI map in QTP during run-time?</h4>
<p>Use methods of <em>RepositoriesCollection</em> object: Find / Add / Remove. See <a href="http://automation-beyond.com/2008/04/15/gui-repositories-qtp/" target="_blank">sample code</a>, read <a href="http://automation-beyond.com/2010/03/18/qtp-performance-test/" target="_blank">investigation results</a>.</p>
<h4>What&#8217;s the name of add-in for MS Dynamics Great Plains automation?</h4>
<p>There is no specific add-in. You would need Dot NET and Visual Age add-ins to <a href="http://automation-beyond.com/chapters/projects/gp-automation/" target="_blank">create your own</a>.</p>
<h4>How to restore/resize minimized browser window?</h4>
<p>You need to retrieve handle of a browser window, then operate the window with standard functions. <a href="http://automation-beyond.com/2009/06/25/overload-vbscript/" target="_blank">See sample code</a> (<em>Objective 1</em> chapter in the article).</p>
<h4>How to copy folder with subfolders and files on it?</h4>
<p>You can use XCopy.exe or other command line tool. <a href="http://automation-beyond.com/2010/05/03/creating-folder-structure-from-template/" target="_blank">See sample code</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h4>How to create and edit Great Plains Dexterity macros?</h4>
<ol>
<li>Enable <em>Advanced</em> macro menu (will appear as <em>Tools/Macro/Advanced</em>) by setting <em>ShowAdvancedMacroMenu=TRUE</em> in Dexterity configuration file <em>Dex.ini</em>.</li>
<li>Use <em>Record</em> and <em>Pause</em> commands in <em>Advanced</em> macro menu to create your scripts. Scripts are saved as <em>*.mac</em> files. You can edit source code manually in any text editor.</li>
<li>Refer to <a href="http://automation-beyond.com/2009/11/12/ms-dynamics-great-plains-macros/" target="_blank">documentation</a> page to see descriptions for macro commands and operators.</li>
</ol>
<p> </p>
<h4>How to enable execution log for  Great Plains Dexterity scripts?</h4>
<p>Use <em>logging</em> command. Example: <em>Logging file ‘:c:GP/Log/maclog.txt’</em><br />
Note non Windows-like syntax.</p>
<h4>How to use data from the manually opened Excel file in automation script ?</h4>
<p>Manually opened Excel workbook is locked. Editing test data while test execution scripts try using then might mess-up test results. But you can try waiting for a short period of time, then duplicating the file, if uninterruptible execution is required. <a href="http://automation-beyond.com/2010/04/08/using-locked-excel-workbook/" target="_blank">See sample code</a>.</p>
<h4>What is Dictionary object in QTP?</h4>
<p><a href="http://msdn.microsoft.com/en-us/library/x4k5wbx4(VS.85).aspx" target="_blank">Dictionary</a> is a standard Microsoft object that stores data in <em>key, item</em> pairs.</p>
<ul>
<li>You can use Dictionary object as an associative array</li>
<li>You can use Dictionary object as a dynamic array</li>
<li>You can use Dictionary object to support <a href="http://automation-beyond.com/2009/05/24/qtp-vbscript/" target="_blank">optional and default parameters</a> for VBScript functions</li>
<li>You can use Dictionary object to implement <a href="http://automation-beyond.com/2010/06/10/excel-data-2-dictionary/" target="_blank">local / global data model</a> in your scripts</li>
<li>You can use Dictionary object as a container for parameters you pass in/out in <a href="http://automation-beyond.com/2010/05/27/qtp-actions-review/" target="_blank">QTP Actions</a></li>
</ul>
<p> </p>
<p>and here&#8217;s the related <a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" target="_blank">function library</a>.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2010/07/01/now-on-quick-testing-tips/" rel="bookmark" class="crp_title">Now on Quick Testing Tips</a></li><li><a href="http://automation-beyond.com/2011/02/22/wta-07-questioning-the-mission/" rel="bookmark" class="crp_title">WTA07: Questioning the Mission</a></li><li><a href="http://automation-beyond.com/2010/11/16/wta01-testing-is-learning/" rel="bookmark" class="crp_title">WTA01: Testing is Learning</a></li><li><a href="http://automation-beyond.com/2010/09/20/on-stackoverflow-1/" rel="bookmark" class="crp_title">&#8220;How do you write your QTP Tests?&#8221; (StackOverflow question)</a></li><li><a href="http://automation-beyond.com/2007/08/10/links-xml/" rel="bookmark" class="crp_title">Link-a-log: XML/XSL/XPath</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Dictionary object for storing Excel data row (QTP, VBScript)</title>
		<link>http://automation-beyond.com/2010/06/10/excel-data-2-dictionary/</link>
		<comments>http://automation-beyond.com/2010/06/10/excel-data-2-dictionary/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 12:57:28 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[MS Excel Data]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[objDictionary]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2864</guid>
		<description><![CDATA[Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Open worksheet &#8211; map cell values to column names. Notes. Heading and trailing space characters are removed To make mapping not case sensitive index is brought to lower case If your spreadsheet allows column name duplication you need to enhance [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F06%252F10%252Fexcel-data-2-dictionary%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20use%20Dictionary%20object%20for%20storing%20Excel%20data%20row%20%28QTP%2C%20VBScript%29%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
Parent page: <a title="Service Functions – Excel (QTP, VBScript)" href="http://automation-beyond.com/2010/01/12/service-functions-excel/" target="_blank">Service Functions – Excel (QTP, VBScript)</a></p>
<h3>Answers</h3>
<p><strong>Description</strong></p>
<p>Connect to Excel through COM - Open workbook - Open worksheet &#8211; map cell values to column names.<br />
Notes.</p>
<ul>
<li>Heading and trailing space characters are removed</li>
<li>To make mapping not case sensitive index is brought to lower case</li>
<li>If your spreadsheet allows column name duplication you need to enhance the presented code by adding unique index to duplicated column names (i.e. &#8220;Name, Name_1, Name_2&#8243;)</li>
</ul>
<p> </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">
'Assumptions:
'Excel file exists
'Workbook is open (XLBook)
'Sheet exists
Set objDataRow = CreateObject(&quot;Scripting.Dictionary&quot;)
'
sSheetIndex = 1
intTargetRow = 123
'
Set objUsedRange = XLBook.Worksheets(sSheetIndex).UsedRange()
'
For Iter = 1 To objUsedRange.Columns.Count
   sCellName = LCase(Trim(objUsedRange.Cells(1,Iter)))
   sCellValue = Trim(objUsedRange.Cells(intTargetRow,Iter))
   objDataRow.Item(sCellName) = sCellValue
   End If
Next
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2010/01/12/service-functions-excel/" rel="bookmark" class="crp_title">Service Functions – Excel (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/" rel="bookmark" class="crp_title">Quick questions &#8211; quick answers</a></li><li><a href="http://automation-beyond.com/2008/09/15/winrunner2qtp-2/" rel="bookmark" class="crp_title">WinRunner to QTP migration notes (2)</a></li><li><a href="http://automation-beyond.com/2009/05/23/excel-vbscript-2/" rel="bookmark" class="crp_title">Mapping Excel col names (QTP, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/06/10/excel-data-2-dictionary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s the deal about QTP Actions?</title>
		<link>http://automation-beyond.com/2010/05/27/qtp-actions-review/</link>
		<comments>http://automation-beyond.com/2010/05/27/qtp-actions-review/#comments</comments>
		<pubDate>Thu, 27 May 2010 13:08:12 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[argument]]></category>
		<category><![CDATA[defaulting]]></category>
		<category><![CDATA[description]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[overloading]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[Parameters]]></category>
		<category><![CDATA[pass]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[result]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[what is Action]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2304</guid>
		<description><![CDATA[QTP Action at a glance      &#8220;Happy Path&#8221; Test Flow    The screenprint above demonstrates sample &#8220;Test&#8221; Flow designed using QTP Actions. &#8220;Happy Path&#8221; testing, or conformance testing, or checking can be characterized by 2 attributes: it is scripted, and it ignores everything that is out of scope. Scripted here does not mean a program [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F05%252F27%252Fqtp-actions-review%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22What%27s%20the%20deal%20about%20QTP%20Actions%3F%22%20%7D);"></div>
<h3 style="text-align: center;">QTP Action at a glance</h3>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>    </p>
<h4 style="text-align: center;">&#8220;Happy Path&#8221; Test Flow</h4>
<p><a href="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionTree.jpg"></a><a href="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionTree.jpg"></a> <a href="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionTree.jpg"><img class="alignnone size-full wp-image-2316" style="border: black 1px solid;" title="ActionTree" src="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionTree.jpg" alt="" width="450" height="223" /></a> </p>
<p>The screenprint above demonstrates sample &#8220;Test&#8221; Flow designed using QTP Actions.<br />
&#8220;Happy Path&#8221; testing, or conformance testing, or checking can be characterized by 2 attributes: it is scripted, and it ignores everything that is out of scope. Scripted here does not mean a program written in scripting language. It means a predefined sequence of actions to perform. </p>
<h4 style="text-align: center;">Action-centric design</h4>
<p style="text-align: center;"><a href="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionCentric.jpg"><img class="alignnone size-full wp-image-2308" style="border: black 1px solid;" title="ActionCentric" src="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionCentric.jpg" alt="" width="533" height="414" /></a>    </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>    </p>
<p>Test Action is not only a sequence of steps to perform. They have to be supported with GUI mapping information to recognize objects and test data to use.<br />
QTP provides first in a form of Object Repository component. Each Action is provided with one or more components of this type. Default, automatically attached component is called &#8220;Local&#8221; repository. All GUI objects, captured during recording operations, are stored there. Additional components, that saved in separate files (*.TSR), can be attached to a number of Actions; they are named shared repositories. Attached shared repository appears in the list under its file&#8217;s name (&#8220;Login.tsr&#8221; in the example).<br />
Even if the all object references are written in Descriptive Programming notation, Local Repository remains attached to Action.<br />
QTP provides a built-in Data Model that comes in forms of a workbook (DataTable object) and XML structure (Environment object). These objects are global, i.e. accessible from any Action. In addition, QTP automatically creates a worksheet for each new Action created. This worksheet, named after the Action, is associated with it. That creates a convenience of automatically loading Test Data, associated with Actions. </p>
<h4 style="text-align: center;">Declaration and calling mechanism</h4>
<p style="text-align: left;">As QTP Actions are not regular sub-routines, like functions and subs, they have to be declared; that includes requirement to specify arguments that can be passed into Actions.  </p>
<p><a href="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionParameters.jpg"><img class="alignnone size-full wp-image-2314" title="ActionParameters" src="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionParameters.jpg" alt="" width="470" height="446" /></a>  </p>
<p style="text-align: left;">User can specify arguments by type, or leave it as variant (&#8220;Any&#8221; item in Type selection list). Value of an argument can be defaulted, i.e. if it was omitted in the calling statement the Action will receive the default value. This mechanism represents a limited overloading capacity. (<a href="http://automation-beyond.com/2009/06/25/overload-vbscript/" target="_blank">Read more</a> about custom implementation of overloading and defaulting with VBScript.)  </p>
<p style="text-align: left;">Inside Actions, parameters are accessed through <em>Parameter</em> object.  </p>
<p style="text-align: center;"><a href="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionCode.jpg"><img class="alignnone size-full wp-image-2318" style="border: black 1px solid;" title="ActionCode" src="http://automation-beyond.com/wp/wp-content/uploads/2010/05/ActionCode.jpg" alt="" width="462" height="213" /></a>  </p>
<p style="text-align: left;"><em>Parameter</em> object is similar to <em>Dictionary</em> object, but does not support <em>Count</em> property, and methods like <em>Items()</em> or <em>Keys()</em> .  </p>
<p style="text-align: left;">Last but not least: <em>ExitAction</em> statement allows returning only a constant value.  </p>
<h3 style="text-align: center;">Applicability Notes</h3>
<p style="text-align: left;">The built-in QTP framework is designed for non-programmers trying to implement &#8220;Happy Path&#8221; testing. For that purpose, it fits perfectly. It takes care of initialization and finalization steps, provides ready-to-go structure for test scripts, automatically loads/unloads data associated with the tests, provides rich checking functionalities. It represents evolution of <a href="http://automation-beyond.com/2009/05/31/test-automation-practices-recordplayback-enhanced/" target="_blank">Enhanced Record/Playback</a> approach.  </p>
<p style="text-align: left;">It is applicable at its best for the following scenarios:  </p>
<p style="text-align: left;">
<ul>
<li>small application or application with small independent functionalities that are not cross-tested;</li>
<li>simple GUI that experiences no fluctuations from build to build;</li>
<li>straight and simple business logic, with no or minimal number of pop-up dialogs;</li>
<li>extremely simple test logic, implementing positive, &#8220;happy path&#8221; test cases, with no branching or looping;</li>
<li style="text-align: left;">static dataset, or extremely small number of test data, hard-coded in QTP worksheets.</li>
</ul>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2011/10/24/wta20-flying-solo-no-big-deal/" rel="bookmark" class="crp_title">WTA20: Flying Solo No Big Deal</a></li><li><a href="http://automation-beyond.com/2010/12/01/bugs-go-hard-copy/" rel="bookmark" class="crp_title">Bugs go hard-copy</a></li><li><a href="http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/" rel="bookmark" class="crp_title">Quick questions &#8211; quick answers</a></li><li><a href="http://automation-beyond.com/2010/10/15/notes-on-debrief/" rel="bookmark" class="crp_title">Notes on Testing Challenge debrief</a></li><li><a href="http://automation-beyond.com/2007/09/17/telling-testing-story/" rel="bookmark" class="crp_title">Telling testing story</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/05/27/qtp-actions-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SetACL command line examples</title>
		<link>http://automation-beyond.com/2010/04/27/setacl-command-line-examples/</link>
		<comments>http://automation-beyond.com/2010/04/27/setacl-command-line-examples/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 13:18:36 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[2. Testing]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[deny]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[grant]]></category>
		<category><![CDATA[Implementation]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SetACL]]></category>
		<category><![CDATA[settings]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2165</guid>
		<description><![CDATA[I found SetACL tool very handy. In addition to implementation of security settings in batch files (that&#8217;s what it was created for), I quite successfully used it in automation of infrastructure maintenance and testing jobs that occure daily and even hourly. As any command line tool, powerful but simple, it requires instructions written in its [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F04%252F27%252Fsetacl-command-line-examples%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22SetACL%20command%20line%20examples%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>I found <a href="http://automation-beyond.com/2010/04/20/security-tools-setacl/" target="_blank">SetACL</a> tool very handy.<br />
In addition to implementation of security settings in batch files (that&#8217;s what it was created for), I quite successfully used it in automation of <a href="http://automation-beyond.com/2010/02/09/infrastructure-maintenance/" target="_blank">infrastructure maintenance</a> and testing jobs that occure daily and even hourly.</p>
<p>As any command line tool, powerful but simple, it requires instructions written in its own metalanguage. You can find the full reference through this <a href="http://setacl.sourceforge.net/html/doc-reference.html" target="_blank">external link</a>.</p>
<p>Examples below represent some of my findings and experiments.<br />
In the <a href="http://automation-beyond.com/2010/04/29/setacl-command-line-automation/" target="_blank">next post</a> I demonstrate using of SetACL in automation scripts.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h4>Protect &#8216;Child01&#8242; folder from permission inheritance</h4>
<p>I.e. Set &#8220;Allow inheritable permissions from the parent object to propagate to this object&#8221; checkbox to &#8220;Off&#8221;.</p>
<pre class="brush: vb; title: ;">
C:\Test&gt;setacl -on &quot;C:\Test\Parent\Child01&quot; -ot file -actn setprot -op &quot;dacl:p_c;sacl:p_c&quot;
</pre>
<h4>Deny access to common user groups</h4>
<p> &#8221;Users&#8221;, &#8220;Domain Users&#8221; can no longer access the folder.</p>
<pre class="brush: vb; title: ;">
C:\Test&gt;setacl -on &quot;C:\Test\Parent\Child01&quot; -ot file -actn trustee -trst &quot;n1:users;ta:remtrst;w:dacl&quot; -actn trustee -trst &quot;n1:domain users;ta:remtrst;w:dacl&quot;
</pre>
<h4>Allow access for a user account</h4>
<p>&#8220;Change&#8221; permission is assigned to &#8221;testuser&#8221; user account. Now the user is allowed to modify the folder (&#8220;Child01&#8243;) and has full control on all of its children objects.</p>
<pre class="brush: vb; title: ;">
C:\Test&gt;setacl -on &quot;C:\Test\Parent\Child01&quot; -ot file -actn ace -ace &quot;n:testuser;p:change&quot;
</pre>
<h4>Set special permissions for &#8217;Child01&#8242; </h4>
<p>Now &#8220;testuser&#8221; can not delete its own root folder (&#8220;Child01&#8243;).</p>
<pre class="brush: vb; title: ;">
C:\Test&gt;setacl -on &quot;C:\Test\Parent\Child01&quot; -ot file -actn ace -ace &quot;n:testuser;p:delete;i:np;m:deny;w:dacl&quot;
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2010/04/29/setacl-command-line-automation/" rel="bookmark" class="crp_title">SetACL command line automation examples</a></li><li><a href="http://automation-beyond.com/2010/04/20/security-tools-setacl/" rel="bookmark" class="crp_title">Security Administration Tool &#8211; (Open Source) SetACL</a></li><li><a href="http://automation-beyond.com/2010/05/03/creating-folder-structure-from-template/" rel="bookmark" class="crp_title">Creating folder structure from a template (Excel/VBA)</a></li><li><a href="http://automation-beyond.com/2009/12/21/loops-dexterity-macro/" rel="bookmark" class="crp_title">How to use loops in Dexterity Macro</a></li><li><a href="http://automation-beyond.com/2010/03/25/security-tools-cacls/" rel="bookmark" class="crp_title">Security Administration Tool &#8211; Microsoft CACLS</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/04/27/setacl-command-line-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use test data from a locked Excel Workbook (QTP, VBScript)</title>
		<link>http://automation-beyond.com/2010/04/08/using-locked-excel-workbook/</link>
		<comments>http://automation-beyond.com/2010/04/08/using-locked-excel-workbook/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 12:07:14 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[MS Excel Data]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[locked]]></category>
		<category><![CDATA[opened]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[read-only]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[workaround]]></category>
		<category><![CDATA[workbook]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2147</guid>
		<description><![CDATA[Parent page: Service Functions – Excel (QTP, VBScript) Question The question was asked here. How can I get data from Excel spreadsheet if it is accidentally open? It ruins whole batch execution. While opening manually I can go “read-only” and still access it. Is there any way to read data from an open and locked [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F04%252F08%252Fusing-locked-excel-workbook%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20use%20test%20data%20from%20a%20locked%20Excel%20Workbook%20%28QTP%2C%20VBScript%29%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>Parent page: <a title="Service Functions – Excel (QTP, VBScript)" href="http://automation-beyond.com/2010/01/12/service-functions-excel/" target="_blank">Service Functions – Excel (QTP, VBScript)</a></p>
<h3>Question</h3>
<p>The question was asked <a href="http://automation-beyond.com/2009/05/23/excel-vbscript-2/#comment-848" target="_blank">here</a>.</p>
<blockquote><p>How can I get data from Excel spreadsheet if it is accidentally open? It ruins whole batch execution.<br />
While opening manually I can go “read-only” and still access it.<br />
Is there any way to read data from an open and locked Excel file from QTP?</p></blockquote>
<h3>Answer</h3>
<p>You can programmatically open an Excel workbook and check whether it&#8217;s accessible as read-only.</p>
<p>If you need to get a full control of Excel data files during a batch execution of scripts I suggest the following logic.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>Description</strong></p>
<p>1. <a href="http://automation-beyond.com/2010/04/07/check-if-workbook-is-locked/" target="_blank">Check</a> if Excel Workbook is locked</p>
<p>2. <a href="http://automation-beyond.com/2009/12/15/how-to-duplicate-existing-file/" target="_blank">Create</a> a duplicate file</p>
<p>3. Use duplicated file as a data source</p>
<p>4. Delete when you no longer need it</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2010/01/12/service-functions-excel/" rel="bookmark" class="crp_title">Service Functions – Excel (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/04/07/check-if-workbook-is-locked/" rel="bookmark" class="crp_title">How to check if Excel Workbook is locked</a></li><li><a href="http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/" rel="bookmark" class="crp_title">Quick questions &#8211; quick answers</a></li><li><a href="http://automation-beyond.com/2009/05/23/excel-vbscript-2/" rel="bookmark" class="crp_title">Mapping Excel col names (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/01/21/how-to-add-excel-macro-from-qtp/" rel="bookmark" class="crp_title">How to add (create) Excel macro from QTP</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/04/08/using-locked-excel-workbook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to check if Excel Workbook is locked</title>
		<link>http://automation-beyond.com/2010/04/07/check-if-workbook-is-locked/</link>
		<comments>http://automation-beyond.com/2010/04/07/check-if-workbook-is-locked/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 13:29:05 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[MS Excel Data]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[locked]]></category>
		<category><![CDATA[opened]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[read-only]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[workbook]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2150</guid>
		<description><![CDATA[Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Check property. Public Function ReadOnlyWorkbook(ByVal sFileName)  Dim objXLBook, objXLHandle  Dim FSO, boolRC    Set FSO = CreateObject(&#34;Scripting.FileSystemObject&#34;)  boolRC = FSO.FileExists(sFileName)  Set FSO = Nothing  If Not boolRC Then   ReadOnlyWorkbook = FALSE   Exit Function  End If ' Set objXLHandle =  CreateObject(&#34;Excel.Application&#34;) [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F04%252F07%252Fcheck-if-workbook-is-locked%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20check%20if%20Excel%20Workbook%20is%20locked%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>Parent page: <a href="http://automation-beyond.com/2010/01/12/service-functions-excel/" target="_blank">Service Functions – Excel (QTP, VBScript)</a></p>
<h3>Answers</h3>
<p><strong>Description</strong></p>
<p>Connect to Excel through COM - Open workbook - Check property.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: vb; title: ;">Public Function ReadOnlyWorkbook(ByVal sFileName)
 Dim objXLBook, objXLHandle
 Dim FSO, boolRC
 
 Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
 boolRC = FSO.FileExists(sFileName)
 Set FSO = Nothing
 If Not boolRC Then
  ReadOnlyWorkbook = FALSE
  Exit Function
 End If

'

Set objXLHandle =  CreateObject(&quot;Excel.Application&quot;)
 objXLHandle.DisplayAlerts = False
  
 Set objXLBook = objXLHandle.WorkBooks.Open(sFileName)
 objXLBook.Activate
 

'Retrieve state
 ReadOnlyWorkbook = objXLHandle.ActiveWorkBook.ReadOnly

'release objects

 objXLBook.Close
 objXLHandle.Quit

 Set objXLBook = Nothing
 Set objXLHandle = Nothing
End Function
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2010/04/08/using-locked-excel-workbook/" rel="bookmark" class="crp_title">How to use test data from a locked Excel Workbook (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/01/12/service-functions-excel/" rel="bookmark" class="crp_title">Service Functions – Excel (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/10/17/how-to-open-excel-workbook-qtp-vbscript/" rel="bookmark" class="crp_title">How to open Excel workbook (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2010/06/22/quick-questions-quick-answers/" rel="bookmark" class="crp_title">Quick questions &#8211; quick answers</a></li><li><a href="http://automation-beyond.com/2009/05/23/excel-vbscript-2/" rel="bookmark" class="crp_title">Mapping Excel col names (QTP, VBScript)</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/04/07/check-if-workbook-is-locked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing files contained in a folder</title>
		<link>http://automation-beyond.com/2010/03/15/processing-files-in-folder/</link>
		<comments>http://automation-beyond.com/2010/03/15/processing-files-in-folder/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 13:17:20 +0000</pubDate>
		<dc:creator>Albert Gareev</dc:creator>
				<category><![CDATA[File System Operations]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[.Exists]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[filename unknown]]></category>
		<category><![CDATA[FileSystemObject]]></category>
		<category><![CDATA[FSO]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[QTP]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://automation-beyond.com/?p=2001</guid>
		<description><![CDATA[Reference page: Service Functions – System (QTP, VBScript) Question The question was asked here. I need to check number of text files in the folder but i dont know names Answer Checking what number of files is contained in a folder is simple. More challenging tasks would be processing files based on type or name [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fautomation-beyond.com%252F2010%252F03%252F15%252Fprocessing-files-in-folder%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Processing%20files%20contained%20in%20a%20folder%22%20%7D);"></div>
<p><div style="position: relative; z-index:1;"><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* Banner 468x60 */
google_ad_slot = "8933038987";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>Reference page: <a title="Service Functions – System (QTP, VBScript)" href="http://automation-beyond.com/2009/12/05/service-functions-system/" target="_blank">Service Functions – System (QTP, VBScript)</a></p>
<h3>Question</h3>
<p>The question was asked <a href="http://automation-beyond.com/2009/10/24/how-to-check-if-file-exists/" target="_blank">here</a>.</p>
<blockquote><p>I need to check number of text files in the folder but i dont know names</p></blockquote>
<h3>Answer</h3>
<p>Checking what number of files is contained in a folder is simple. More challenging tasks would be processing files based on type or name patterns.</p>
<p><strong>Implementation</strong></p>
<p><strong>1. Retrieve total number of files</strong><strong> </strong></p>
<pre class="brush: vb; title: ;">
Dim sParentFolder

sParentFolder = &quot;C:\TEMP&quot;

Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
boolRC = FSO.FolderExists(sParentFolder)
Set FSO = Nothing 'release an object
If Not boolRC Then
'do what you need to do if
'folder does not exist
End If

Set objParentFolder = FSO.GetFolder(sParentFolder)

Set objFilesColl = objParentFolder.Files

'objFilesColl.Count contains total number of files
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4470793787913935";
/* 4 links text line */
google_ad_slot = "5367351963";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>2. Count files based on extension</strong><strong> </strong></p>
<p>Used resources: <a title="Service Functions – String (QTP, VBScript)" href="http://automation-beyond.com/2009/10/01/service-functions-string/" target="_blank">Service Functions – String (QTP, VBScript)</a></p>
<p>In the second example number of text files is just counted. Excel files&#8217; names are stored in Dictionary object for further processing.</p>
<pre class="brush: vb; title: ;">Dim sFolder
Dim FSO, objFolder, objFile, objXLSList
Dim intTXTCount

sFolder = &quot;C:\TEMP&quot;

Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objXLSList = CreateObject(&quot;Scripting.Dictionary&quot;)

Set objFolder = FSO.GetFolder(sFolder)
intTXTCount = 0
For Each objFile In objFolder.Files
 If Regex_Test(objFile.Name, &quot;.*\.[t,T][t,T][t,T]&quot;) Then
  intTXTCount = intTXTCount + 1
 End If
 If Regex_Test(objFile.Name, &quot;.*\.[x,X][l,L][s,S]&quot;) Then
  objXLSList.Add objXLSList.Count, objFile.Name
 End If
Next
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://automation-beyond.com/2009/12/05/service-functions-system/" rel="bookmark" class="crp_title">Service Functions – System (QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2009/01/09/service-functions-dictionary/" rel="bookmark" class="crp_title">Service Functions – Dictionary (QTP, TestComplete, VBScript)</a></li><li><a href="http://automation-beyond.com/2011/07/26/how-to-find-last-modified-file/" rel="bookmark" class="crp_title">How to find last modified file (TestComplete, QTP, VBScript)</a></li><li><a href="http://automation-beyond.com/2007/06/15/test-automation-architecture-winrunner/" rel="bookmark" class="crp_title">Test Automation Architecture (WinRunner)</a></li><li><a href="http://automation-beyond.com/2009/05/27/vbscript-xml-xsl-2/" rel="bookmark" class="crp_title">Text File compare in &#8220;WDIFF&#8221; style (QTP, VBScript, XML, XSL) &#8211; Instructions and XSL script</a></li></ul></div>
]]></content:encoded>
			<wfw:commentRss>http://automation-beyond.com/2010/03/15/processing-files-in-folder/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

