<?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/"
	>

<channel>
	<title>TechBlog &#187; vbs</title>
	<atom:link href="http://techblog.byllemos.com/tag/vbs/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.byllemos.com</link>
	<description>Accelerating into the Future with Wisdom about Technology! Ingrid Byllemos</description>
	<lastBuildDate>Tue, 05 Jan 2010 00:04:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Splitting files using Visual Basic Scripts</title>
		<link>http://techblog.byllemos.com/2008/05/splitting-files-using-visual-basic-scripts/</link>
		<comments>http://techblog.byllemos.com/2008/05/splitting-files-using-visual-basic-scripts/#comments</comments>
		<pubDate>Wed, 21 May 2008 20:02:35 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Basic]]></category>
		<category><![CDATA[Scripting.FileSystemObject]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=69</guid>
		<description><![CDATA[<p>Do you occasionally need to split a file based on its content? </p>
<p>If yes &#8211; then this can be done quickly by using a Visual Basic Script and &#8220;Scripting.FileSystemObject&#8221;.</p>
<p>Lets take a closer look.<br />
<span id="more-69"></span><br />
First you&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Do you occasionally need to split a file based on its content? </p>
<p>If yes &#8211; then this can be done quickly by using a Visual Basic Script and &#8220;Scripting.FileSystemObject&#8221;.</p>
<p>Lets take a closer look.<br />
<span id="more-69"></span><br />
First you have to define your source file and destination file.</p>
<blockquote><p>
FileCount = 0<br />
DestFileName = &#8220;C:\destination&#8221;&#038;FileCount&#038;&#8221;.txt&#8221;</p>
<p>Set objFileSystemObject = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br />
Set objSource = objFileSystemObject.OpenTextFile(&#8220;C:\sourcefile.txt&#8221;, ForReading)<br />
Set objDestination = objFileSystemObject.CreateTextFile(DestFileName, True)
</p></blockquote>
<p>Next you have to run through the Source File and write it to destinations files.</p>
<blockquote><p>
&#8216;File Separator Mark<br />
NewFileContent = &#8220;&#8211;start&#8221;</p>
<p>&#8216;Run through the file<br />
Do Until objSource.AtEndOfStream<br />
<blankspace>&#8230;&#8230;</blankspace>&#8216;Read a line<br />
<blankspace>&#8230;&#8230;</blankspace>strLine = objSource.ReadLine</p>
<p><blankspace>&#8230;&#8230;</blankspace>&#8216;Check if a new file should be created<br />
<blankspace>&#8230;&#8230;</blankspace>If InStr(1, strLine, NewFileContent) > 0 Then<br />
<blankspace>&#8230;&#8230;&#8230;..</blankspace>&#8216;Close Previous File<br />
<blankspace>&#8230;&#8230;&#8230;..</blankspace>objDestination.Close<br />
<blankspace>&#8230;&#8230;&#8230;..</blankspace>Set objDestination = Nothing</p>
<p><blankspace>&#8230;&#8230;&#8230;..</blankspace>&#8216;Create New FileName<br />
<blankspace>&#8230;&#8230;&#8230;..</blankspace>FileCount = FileCount + 1<br />
<blankspace>&#8230;&#8230;&#8230;..</blankspace>DestFileName = &#8220;C:\destination&#8221;&#038;FileCount&#038;&#8221;.txt&#8221;</p>
<p><blankspace>&#8230;&#8230;&#8230;..</blankspace>&#8216;Create and Open New File<br />
<blankspace>&#8230;&#8230;&#8230;..</blankspace>Set objDestination = objFileSystemObject.CreateTextFile(DestFileName, True)<br />
<blankspace>&#8230;&#8230;</blankspace>End If</p>
<p><blankspace>&#8230;&#8230;</blankspace>&#8216;Write to the file<br />
<blankspace>&#8230;&#8230;</blankspace>objDestination.WriteLine (strLine)<br />
Loop
</p></blockquote>
<p>And the finally end by closing the open files</p>
<blockquote><p>
objSource.Close<br />
objDestination.Close</p>
<p>Set objSource = Nothing<br />
Set objDestination = Nothing<br />
Set objFileSystemObject = Nothing
</p></blockquote>
<p>In the above example a file looking like this</p>
<blockquote><p>
&#8211;start<br />
my first file<br />
&#8211;start<br />
my second file<br />
&#8211;start<br />
my third file
</p></blockquote>
<p>would be split in to the files:</p>
<blockquote><p>
destination1.txt containing:<br />
&#8211;start<br />
my first file
</p></blockquote>
<blockquote><p>
destination2.txt containing:<br />
&#8211;start<br />
my second file
</p></blockquote>
<blockquote><p>
destination3.txt containing:<br />
&#8211;start<br />
my third file
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/05/splitting-files-using-visual-basic-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sendkeys in Visual Basic Scripts</title>
		<link>http://techblog.byllemos.com/2008/02/sendkeys-in-visual-basic-scripts/</link>
		<comments>http://techblog.byllemos.com/2008/02/sendkeys-in-visual-basic-scripts/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 21:56:48 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Basic]]></category>
		<category><![CDATA[Sendkeys]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[WshShell]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=43</guid>
		<description><![CDATA[<p>Sendkeys can also be used from a Visual Basic Scripts, which means you can ex. build a vbs file, that can be used for starting up applications, or executing steps that you often have to do.</p>
<p>This is an example&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Sendkeys can also be used from a Visual Basic Scripts, which means you can ex. build a vbs file, that can be used for starting up applications, or executing steps that you often have to do.</p>
<p>This is an example on starting the Notepad and afterwards, as the first thing to do writing the word Hallo:<span id="more-43"></span></p>
<blockquote><p> set WshShell = WScript.CreateObject(&#8220;WScript.Shell&#8221;)<br />
WshShell.Run &#8220;notepad&#8221;</p>
<p>WScript.Sleep 100</p>
<p>WshShell.AppActivate &#8220;Notesblok&#8221;<br />
WshShell.SendKeys &#8220;Hallo&#8221;</p>
<p>Set WshShell = nothing</p></blockquote>
<p>Lets take a closer look on what the script actual do. The first step is to initiate the object:</p>
<p>set WshShell = WScript.CreateObject(&#8220;WScript.Shell&#8221;)</p>
<p>when the object is initiate, the Notepad application is being startet:</p>
<blockquote><p>WshShell.Run &#8220;notepad&#8221;</p></blockquote>
<p>To be sure that notepad is up and running, there has to be a kind of wait state before continuing. This is done be telling the script to Sleep x milliseconds:</p>
<blockquote><p>WScript.Sleep 100</p></blockquote>
<p>Now the Notepad application has to be activated:</p>
<blockquote><p>WshShell.AppActivate &#8220;Notesblok&#8221;</p></blockquote>
<p>Once Notepad has been activated, it is ready to receive keys. Which now can be send with the sendkeys command:</p>
<blockquote><p>WshShell.SendKeys &#8220;Hallo&#8221;</p></blockquote>
<p>Finally you have to clean up after you &#8211; which means, to stop / close the WshShell you have to set it to nothing.</p>
<blockquote><p>Set WshShell = nothing</p></blockquote>
<p>Thats it &#8211; now you have written the Visual Basic Script &#8211; and all you have to do is save it as a vbs file, or incorporate it into a web page using th vbscript tags.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/02/sendkeys-in-visual-basic-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

