<?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>Life...as it relates to Technology. &#187; VBA/VSTO</title>
	<atom:link href="http://www.hobbub.com/category/vba-vb-vsto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hobbub.com</link>
	<description>Technology, Internet and Real World Product Reviews.</description>
	<lastBuildDate>Wed, 14 Jul 2010 04:45:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating a Wordpress Import File with Excel</title>
		<link>http://www.hobbub.com/vba-vb-vsto/creating-a-wordpress-import-file-with-excel/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/creating-a-wordpress-import-file-with-excel/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 23:55:01 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Wordpress Import]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/vba-vb-vsto/creating-a-wordpress-import-file-with-excel/</guid>
		<description><![CDATA[Wordpress Import Files Using Excel
Disclaimer: I absolutely do not advocate splogging of any kind. This is simply a way to get your existing data into a Wordpress blog. This same method could be used for chapters in book, recipes, or whatever other kind of data you may have. Rather than taking the monumental effort of [...]]]></description>
			<content:encoded><![CDATA[<h3>Wordpress Import Files Using Excel</h3>
<p><small><b>Disclaimer:</b> I absolutely do not advocate splogging of any kind. This is simply a way to get your existing data into a Wordpress blog. This same method could be used for chapters in book, recipes, or whatever other kind of data you may have. Rather than taking the monumental effort of manually creating a Wordpress site based on your work, you can use a little creativity to come up with a fast, easy solution that is surprisingly robust (this article creates a Wordpress blog website with over 31,000 posts).</small></p>
<p>I&#8217;m a big fan of <i>native file formats</i> &#8211; as they say, &#8220;when in rome&#8221;&#8230;. Yeah. Anyway, this is a quick article to illustrate how to set up <b>Wordpress Import</b> using an Excel spreadsheet. I&#8217;ll try to cover this from point A to point Z and even provide the download files and set up a sample URL so you can see the results.</p>
<p>The <b>Wordpress 2.8 Import File</b> screen lists fifteen different file formats including: Blogger, Blogroll, Blogware, Bunny’s Technorati Tags, Categories and Tags Converter, DotClear, GreyMatter, Jerome’s Keywords, LiveJournal, Movable Type and TypePad, RSS, Simple Tagging, Textpattern, Ultimate, and WordPress. I would be lying if I claimed to know what any of these formats actually are, so I&#8217;m going to go the easy route and export a file and use it as a template.</p>
<p>The Wordpress export file saves out as a <i>.wxr file</i>. This format is called the <b>WordPress eXtended RSS file format </b>and contains posts, pages, comments, custom fields, categories, and tags. After performing a Wordpress Blog Export from another blog, I can see that what I&#8217;m primarily concerned with is the &#8220;item&#8221; section which corresponds to a post. I&#8217;ll chop out the &#8220;item&#8221; section and save it as its own file. This will be a template that I&#8217;ll use later on from VBA. (I cut a couple elements from the bottom as well which I doubted were required by the schema &#8211; flying fast and loose on this one. You&#8217;d want to make sure your file conforms with any applicable XSD or DTD, but I&#8217;m fairly confident this will work.)</p>
<p>I&#8217;m inserting some placeholders in the template sample Wordpress Import file. These placeholders will be search and replaced as we create the actual import file(s). Here is the XML snippet of the template and here is the file available to download (coming soon).</p>
<p><font face="Courier New">&lt;item&gt;<br />&nbsp;&nbsp;&nbsp; &lt;title&gt;[propertitle]&lt;/title&gt;<br />&nbsp;&nbsp;&nbsp; &lt;link&gt;[link]&lt;/link&gt;<br />&nbsp;&nbsp;&nbsp; &lt;pubDate&gt;Fri, 12 Jun 2009&lt;/pubDate&gt;<br />&nbsp;&nbsp;&nbsp; &lt;dc:creator&gt;&lt;![CDATA[admin]]&gt;&lt;/dc:creator&gt;<br />&nbsp;&nbsp;&nbsp; &lt;category&gt;&lt;![CDATA[[category]]]&gt;&lt;/category&gt;<br />&nbsp;&nbsp;&nbsp; &lt;category domain=&#8221;category&#8221; nicename=&#8221;[category]&#8220;&gt;&lt;![CDATA[[category]]]&gt;&lt;/category&gt;<br />&nbsp;&nbsp;&nbsp; &lt;guid isPermaLink=&#8221;false&#8221;&gt;http://www.biblewack.com/[testament]/[category]/[hyphen]/&lt;/guid&gt;<br />&nbsp;&nbsp;&nbsp; &lt;description&gt;&lt;/description&gt;<br />&nbsp;&nbsp;&nbsp; &lt;content:encoded&gt;&lt;![CDATA[[content]<br />&lt;p align=&#8221;center&#8221;&gt;&lt;span style=&#8221;font-size: x-small;&#8221;&gt;<br />&lt;a title=&#8221;[backtitle]&#8221; href=&#8221;[backlink]&#8220;&gt;&amp;lt;&amp;lt; [backtitle]&lt;/a&gt; || &lt;a title=&#8221;[nexttitle]&#8221; href=&#8221;[nextlink]&#8220;&gt;[nexttitle] &amp;gt;&amp;gt;&lt;/a&gt;&lt;/span&gt;<br />]]&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/content:encoded&gt;<br />&nbsp;&nbsp;&nbsp; &lt;excerpt:encoded&gt;&lt;![CDATA[[content]]]&gt;&lt;/excerpt:encoded&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_id&gt;[postid]&lt;/wp:post_id&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_date&gt;2009-06-12&lt;/wp:post_date&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_date_gmt&gt;2009-06-12&lt;/wp:post_date_gmt&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:comment_status&gt;open&lt;/wp:comment_status&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:ping_status&gt;open&lt;/wp:ping_status&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_name&gt;[hyphen]&lt;/wp:post_name&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:status&gt;publish&lt;/wp:status&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_parent&gt;0&lt;/wp:post_parent&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:menu_order&gt;0&lt;/wp:menu_order&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_type&gt;post&lt;/wp:post_type&gt;<br />&nbsp;&nbsp;&nbsp; &lt;wp:post_password&gt;&lt;/wp:post_password&gt;<br />&lt;/item&gt;</font><br />
<h4>Programming the Wordpress Upload</h4>
<p>So, I wanted to create a big Wordpress site for this example &#8211; really big. I struggled to think of what kind of freely diseminable data I could come up with to create a massive <i>Wordpress Import sample</i>. I found a good source of data with the Bible. Free to distribute and in nice text file format. Each line numbered (think &#8220;unique identifier&#8221;) and each line with a hard return after it. A perfect data structure for import into Excel (and eventual import into Wordpress). I&#8217;ll digress from the Wordpress Import briefly to illustrate how I sliced and diced the data to get it ready.</p>
<p>1. Import into Excel without delimiters. 1 column<br />2. Chop out Line Numbers with For-Next Loop and instr(function). 2 columns<br />3. Derive Chapter Name with Lookup function on alpha characters in previously created column. 3 columns<br />4. Assign Old Testament or New Testament with manual drag in Excel. 4 columns<br />5. Figure out what the URLs will be and make URL column. 5 columns</p>
<p>The reason I wanted to figure out the absolute URL for each post is I wanted to include &#8220;back&#8221; and &#8220;next&#8221; links in the body of each post so one could traverse throughout the entire book from post to post. This is accomplished simply by looking at the previous row (x-1) and the next row (x+1) while executing the loop.</p>
<p>Here is the entirety of the routine to create the .wrx Import file. You may need to split your file up differently depending on your import limits. You can easily do this by saving out a file every XXXX-th time or whatever you need. The code is very simple to understand. I loop through every data row in the spreadsheet (31102 rows and a header). Variables are assigned to the cell string values. A string variable &#8220;S&#8221; is assigned the result of our <a href="http://www.hobbub.com/vba-vb-vsto/text-file-to-string-vb-function/" title="vba text to string function">Text2String </a>function. As I&#8217;m thinking about it now in retrospect, rather than call that code every time &#8211; you could just call it initially and create S once. Then you could assign another variable to the value of S every time rather than going through the readfile process, much more efficient&#8230;..Oh well&#8230; Lastly, I append the contents of S into a file using Print. </p>
<p><font face="Courier New">Sub makeWordpressImportFile()</p>
<p>For x = 2 To 31103</p>
<p>sPostid = x<br />sCategory = Trim(LCase(Sheet1.Cells(x, 2)))<br />sCategory = Replace(sCategory, &#8221; &#8220;, &#8220;-&#8221;)<br />sTestament = Trim(LCase(Sheet1.Cells(x, 1)))<br />sTestament = Replace(sTestament, &#8221; &#8220;, &#8220;-&#8221;)<br />sBackTitle = Trim(Sheet1.Cells(x &#8211; 1, 4))<br />sNextTitle = Trim(Sheet1.Cells(x + 1, 4))<br />sBackLink = Trim(Sheet1.Cells(x &#8211; 1, 7))<br />sNextLink = Trim(Sheet1.Cells(x + 1, 7))<br />sContent = Trim(Sheet1.Cells(x, 8))<br />sLink = Trim(Sheet1.Cells(x, 7))<br />sProperTitle = Trim(Sheet1.Cells(x, 4))<br />sHyphen = Trim(Sheet1.Cells(x, 5))</p>
<p>s = Text2String.Text2String(&#8221;c:\scott\item.txt&#8221;)<br />s = Replace(s, &#8220;[postid]&#8220;, sPostid)<br />s = Replace(s, &#8220;[category]&#8220;, sCategory)<br />s = Replace(s, &#8220;[testament]&#8220;, sTestament)<br />s = Replace(s, &#8220;[backtitle]&#8220;, sBackTitle)<br />s = Replace(s, &#8220;[backlink]&#8220;, sBackLink)<br />s = Replace(s, &#8220;[nexttitle]&#8220;, sNextTitle)<br />s = Replace(s, &#8220;[nextlink]&#8220;, sNextLink)<br />s = Replace(s, &#8220;[content]&#8220;, sContent)<br />s = Replace(s, &#8220;[link]&#8220;, sLink)<br />s = Replace(s, &#8220;[propertitle]&#8220;, sProperTitle)<br />s = Replace(s, &#8220;[hyphen]&#8220;, sHyphen)</p>
<p>MySitemap = &#8220;c:\scott\bible.txt&#8221;<br />&#8217;set and open file for output<br />fnum = FreeFile()<br />Open MySitemap For Append As fnum<br />Print #fnum, s<br />Close #fnum</p>
<p>Next x<br />End Sub<br /></font><br />Finally, if you&#8217;ve been paying attention, you&#8217;ll know that we haven&#8217;t yet created a well formed XML file &#8211; there is no root node. We&#8217;ve essentially concatenated together a bunch of nodes, but there is no root. I doubt very seriously this would import into anything. You could write something to open each file and paste in the root node and matching end node &#8211; or you can manually open and save your files out. I chose the latter as I didn&#8217;t have many files to work with. I used the following as my root node:</p>
<p><font face="Courier New">&lt;rss version=&#8221;2.0&#8243;<br />&nbsp;&nbsp;&nbsp; xmlns:excerpt=&#8221;http://wordpress.org/export/1.0/excerpt/&#8221;<br />&nbsp;&nbsp;&nbsp; xmlns:content=&#8221;http://purl.org/rss/1.0/modules/content/&#8221;<br />&nbsp;&nbsp;&nbsp; xmlns:wfw=&#8221;http://wellformedweb.org/CommentAPI/&#8221;<br />&nbsp;&nbsp;&nbsp; xmlns:dc=&#8221;http://purl.org/dc/elements/1.1/&#8221;<br />&nbsp;&nbsp;&nbsp; xmlns:wp=&#8221;http://wordpress.org/export/1.0/&#8221;<br />&gt;</font></p>
<p>&#8230;and obviously my closing node was simply &#8220;&lt;/rss&gt;&#8221; which indicated the end of file. Once you have your file(s), all you need to do is import it and Wordpress will handle the rest. The categories will be created and the posts will be created. You could obviously fine tune this by working with the dates &#8211; future dating posts does work (you can make it look like you&#8217;re working when you&#8217;re really not!). The sample site that I created is at <a href="http://www.biblewack.com" title="wordpress bible site">www.biblewack.com</a> (very hard finding an available URL with &#8220;bible&#8221; in the title). Good luck.</p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=1091&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/creating-a-wordpress-import-file-with-excel/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Text File to String VB Function</title>
		<link>http://www.hobbub.com/vba-vb-vsto/text-file-to-string-vb-function/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/text-file-to-string-vb-function/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 22:35:51 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[text files]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/vba-vb-vsto/text-file-to-string-vb-function/</guid>
		<description><![CDATA[Here is a quick little VB/VBA function to turn text files (or html files or xml files) into string variables.
Text File to String Variable Function (xml file to string variable, html file to string variable)
There are numerous Internet Programming situations where large pieces of text need to be populated with variable values. On other occasions [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick little VB/VBA function to turn text files (or html files or xml files) into string variables.<br />
<h4>Text File to String Variable Function (xml file to string variable, html file to string variable)</h4>
<p>There are numerous Internet Programming situations where large pieces of text need to be populated with variable values. On other occasions the task could be parsing html files to retrieve SEO information. Yet another common situation is working with XML as a string inside VB. The Microsoft XML objects consume a lot of memory. Sometimes it is more efficient to work with XML as a string instead of consuming the overhead necessary to create XMLHTTP or MSXML objects.</p>
<p>You can also use a xml file as a template for SOAP calls. Simply retrieve the xml as a string, populate some predefined placeholder text and you are ready to call inline webservices. As you&#8217;ll see, turning text into a string is easy &#8211; it doesn&#8217;t matter whether it is <b>xml to string</b> or <b>html to string</b> either.<br />
<h4>The TextToString Function</h4>
<p>The function below is short and relatively straightforward &#8211; feel free to customize it to suit your individual needs. It contains some rudimentary error trapping, but it should be enough to catch common errors and display enough information for easy troubleshooting.</p>
<p>The function contains two variables: the <i>strPath </i>variable is the argument parameter that will contain the absolute path to the file. You may want to implement file extension validation if your project requires a little more &#8216;tightness&#8217; in the code. <i>strBuff </i>acts as a temporary buffer to hold the results until they can be assigned back to the function&#8217;s result.</p>
<p>also called:<br /><font face="monospace">Public Function XMLToString(strPath As String) As String<br /></font><font face="monospace">Public Function HTMLToString(strPath As String) As String<br /></font><br /><font face="monospace">Public Function TextToString(strPath As String) As String<br />&nbsp;&nbsp;&nbsp; Dim strBuff As String<br />&nbsp;&nbsp;&nbsp; On Error GoTo ErrTrap<br />&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; Open strPath For Binary As #1<br />&nbsp;&nbsp;&nbsp; strBuff = Space(LOF(1))<br />&nbsp;&nbsp;&nbsp; Get #1, , strBuff<br />&nbsp;&nbsp;&nbsp; </font><font face="monospace">TextToString </font><font face="monospace">= strBuff<br />&nbsp;&nbsp;&nbsp; Close #1<br />ErrTrap:<br />&nbsp;&nbsp; If Err Then Err.Raise Err.Number, , &#8220;Error from Functions.TextToString &#8221; &amp; Err.Description<br />End Function</font></p>
<p>In a later project, we&#8217;ll be combining this <b>Text to String Function</b> with the <a href="http://www.hobbub.com/vba-vb-vsto/iterating-over-a-directory-with-a-dir-loop-loop-through-directory-vb/" title="Loop Through Directory With Dir">Loop Through Director</a>y routine in order to build content for a Wordpress blog. We&#8217;ll examine how to create upload files by manipulating data in Excel.</p>
<p>Wise Man Say, <a href="http://www.hobbub.com/aphorisms/dont-run-your-head-against-a-stone-wall/" title="Dont Run Head Against Wall">Don&#8217;t Run Your Head Against a Stone Wall</a></p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=1056&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/text-file-to-string-vb-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Iterating over a Directory with a Dir Loop (Loop Through Directory) VB</title>
		<link>http://www.hobbub.com/vba-vb-vsto/iterating-over-a-directory-with-a-dir-loop-loop-through-directory-vb/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/iterating-over-a-directory-with-a-dir-loop-loop-through-directory-vb/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 20:46:03 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>
		<category><![CDATA[dir function]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[vba]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/vba-vb-vsto/iterating-over-a-directory-with-a-dir-loop-loop-through-directory-vb/</guid>
		<description><![CDATA[VBA is potentially the greatest desktop &#8216;hammer&#8217; you have at your disposal. You can pop open any Office application, hit ALT+F11 and be writing code before Visual Studio will even be open on most machines. 
For doing ad hoc work around the office, VBA allows you to do things that applications alone simply aren&#8217;t powerful [...]]]></description>
			<content:encoded><![CDATA[<p>VBA is potentially the greatest desktop &#8216;hammer&#8217; you have at your disposal. You can pop open any Office application, hit ALT+F11 and be writing code before Visual Studio will even be open on most machines. </p>
<p>For doing ad hoc work around the office, VBA allows you to do things that applications alone simply aren&#8217;t powerful enough to do. It seems like I&#8217;m always running into a situation where I need to get information about a bunch of files in a directory. Let&#8217;s say that you just need to retrieve the names of all files in a certain directory and write them to a column in an Excel spreadsheet. </p>
<p>Unfortunately, Excel doesn&#8217;t provide a native way to accomplish such a task. However, the task is reduced to less than 15 lines of code using VBA. The <b>VBA Dir Function</b> is great for iterating over a directory.</p>
<h3>Understanding the Dir Function</h3>
<p>This function returns a <b>String</b> value containing the name of a file, directory, or folder  that matches a specified pattern or file attribute. If you&#8217;re working at the root level of a file structure, the Dir function will also return the volume label of a  drive.<b> </p>
<p>Dir</b> returns the first file name that matches <i>pathname</i> parameter. The trick to looping through a directory is that <b><i>calling Dir with no arguments</i></b> returns any  additional file names that match <i>pathname</i>. You can see an example of this in the code snippet below: the line with the comment, &#8220;get next entry&#8221; is where the Dir function will retrieve the next matching filename.</p>
<p>When <b>Dir</b> can no longer return a match, it returns a zero-length  string (&#8221;"). If a zero-length string is returned, either a new <i>pathname</i> must be passed or an error occurs. You can change to a new  <i>pathname</i> without retrieving all of the file names that match the current  <i>pathname</i>. </p>
<p>NOTE: Do not nest <b>Dir loops</b> and don&#8217;t attempt to call the <b>Dir</b> function recursively.  Calling <b>Dir</b> with the <b>vbDirectory</b> attribute does not continually  return subdirectories. If you think you need to recurse directories, first consider whether you can copy the results of a simple Windows Search to a new directory to achieve your desired results.<br />
<h4>Looping Over Files with Dir, Looping Through Files, Looping Through Directories&#8230;</h4>
<p>The following VB code snippet is pretty easy to understand. There are three variables: strPath, strFile and x. strPath is used to pass the initial parameter to the Dir function. This simply tells Dir which directory to traverse. strFile is used to hold the file name as the code executes and continues to retrieve file names. x is used simply as a counter so that the correct cell in the Excel spreadsheet is updated with the correct filename (Dir doesn&#8217;t return files in any specific order, so you may need to sort them afterward).</p>
<p><font face="monospace">Sub LoopThruDirectory()<br />&nbsp;&nbsp;&nbsp; <br />Dim strPath As String<br />Dim strFile As String<br />Dim x As Integer</p>
<p>&nbsp;&nbsp;&nbsp; strPath = &#8220;C:\temp\datajunction\XMLOUT\&#8221;<br />&nbsp;&nbsp;&nbsp; strFile = Dir(strPath)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; Do While strFile &lt;&gt; &#8220;&#8221;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x = x + 1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sheet1.Cells(x, 1) = strFile<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFile = Dir&nbsp;&nbsp;&nbsp; &#8216; Get next entry.<br />&nbsp;&nbsp;&nbsp; Loop<br />&nbsp;&nbsp;&nbsp; <br />End Sub</font></p>
<p>Wise Man Says, <a href="http://www.hobbub.com/aphorisms/a-bird-in-hand-is-worth-two-in-a-bush/" title="bird in hand">&#8220;A Bird in Hand is Worth Two in Bush&#8221;</a></p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=1049&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/iterating-over-a-directory-with-a-dir-loop-loop-through-directory-vb/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Real World Scenario using Word Templates</title>
		<link>http://www.hobbub.com/tech-general/real-world-scenario-using-word-templates/</link>
		<comments>http://www.hobbub.com/tech-general/real-world-scenario-using-word-templates/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 17:38:35 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Tech General]]></category>
		<category><![CDATA[VBA/VSTO]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/2007/11/09/real-world-scenario-using-word-templates/</guid>
		<description><![CDATA[Merrill Lynch Business Financial Services developed an extensive Word template repository programmed in VBA. The repository consisted of a single network folder that housed over one hundred stand-alone Word templates. Each template launched a userform when invoked that prompted the user for basic information. This information was then used to populate certain areas of the [...]]]></description>
			<content:encoded><![CDATA[<p>Merrill Lynch Business Financial Services developed an extensive Word template repository programmed in VBA. The repository consisted of a single network folder that housed over one hundred stand-alone Word templates. Each template launched a userform when invoked that prompted the user for basic information. This information was then used to populate certain areas of the document and make decisions about which clauses to create.</p>
<p>At the outset, the templates were created by an advanced business user. The templates were originally created merely as shortcuts to create business documentation. However, they incidentally gathered a great deal of foundational business data, such as customer information and transaction terms.<br />
Users quickly became frustrated by having to enter data into two systems: (1) the Word templates, and (2) the central database application.</p>
<p>The IT department was faced with a dilemma; they needed to begin maintaining the templates and enhance their functionality to either pull information from the database, or feed the database directly from the VBA templates. A quick review of the templates found that they didn’t meet any of the internal application guidelines. They weren’t even signed and required users to have their security set to “low” in order to run.<br />
This was clearly an example where a professional development environment (and some forethought) could have prevented a costly project.</p>
<p>Sidenote:<br />
With the development of information technology, most of the people started using <a href="http://www.softwaremarts.com">computers and software</a> for managing their data. Different <a href="http://www.unidata.ucar.edu/software/">software tools</a> are available in market to perform specific tasks, like if you are a tax consultant then defiantly you should have <a href="http://parents.berkeley.edu/recommend/legal/taxsw.html">tax software</a>.</p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=57&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/tech-general/real-world-scenario-using-word-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uniform Credit Write-Up &#8211; Large Sample Automated Word Template (.dot)</title>
		<link>http://www.hobbub.com/vba-vb-vsto/uniform-credit-write-up-large-sample-automated-word-template-dot/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/uniform-credit-write-up-large-sample-automated-word-template-dot/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 21:36:34 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/2007/11/03/uniform-credit-write-up-large-sample-automated-word-template-dot/</guid>
		<description><![CDATA[One of my earliest projects involving Word began as a simple task to create internal “credit write-ups” (write-ups) for a banking institution. These write-ups involved a detailed analysis of the credit worthiness of businesses that were applying for lines of credit and term loans. The write-up contained various sections: business information, guarantor information, collateral description [...]]]></description>
			<content:encoded><![CDATA[<p>One of my earliest projects involving Word began as a simple task to create internal “credit write-ups” (write-ups) for a banking institution. These write-ups involved a detailed analysis of the credit worthiness of businesses that were applying for lines of credit and term loans. The write-up contained various sections: business information, guarantor information, collateral description and evaluation, inventory description and analysis, accounts receivable information, principal information and financial statement analysis.</p>
<p>Procedurally, the information was typed into a Word document and passed through the various channels until “the deal” was either approved or rejected. In the case of an approval, all of the information was then retrieved from the Word document and manually entered into the backend database solution.</p>
<p>The project, as originally conceived, was to write a complex application to parse the Word document, extract the appropriate data and populate the database accordingly. We discussed this solution at length and recommended a “Document Assembly” approach to the business as an alternative. Unstructured Word documents were simply to difficult to parse in a reliable fashion. However, we could let the users enter the data in a very long series of conditional UserForms. The data would be collected and when complete, a document (the original write-up) would be created to memorialize the transaction and receive the appropriate signatures. Once the data was complete, it was a simple manner of transferring said data to the backend database and the need for an entire department was eliminated. The original solution was driven by VBA and designed as a Word template (you can find the original (with trade secret and proprietary data omitted) at <a href="http://www.docbuilder.com/downloads/Sample%20Large%20Template.zip">http:///www.docbuilder.com/downloads/Sample Large Template.zip</a>). This was in 1997.</p>
<p>Note:</p>
<p>A lot of work is undergoing in <a href="http://www.sitecarrier.com">website design</a> and development. If you are planning to develop web site and looking for <a href="http://ccib.mgh.harvard.edu/webdevelopmentcore.htm">web development agency</a> then you don’t need to wait, simply go online and search for <a href="http://www.tsbvi.edu/technology/tools.htm">web design consulting</a>.</p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=53&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/uniform-credit-write-up-large-sample-automated-word-template-dot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fee Credit Calculator &#8211; Need for a VSTO Solution</title>
		<link>http://www.hobbub.com/vba-vb-vsto/fee-credit-calculator-need-for-a-vsto-solution/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/fee-credit-calculator-need-for-a-vsto-solution/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 21:29:35 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/2007/11/03/fee-credit-calculator-need-for-a-vsto-solution/</guid>
		<description><![CDATA[I was involved with a project to create a complicated “Fee Credit Calculator” for a large financial institution. The basis of the project was that large institutional clients paid enormous fees for certain mutual fund transactions. There was a certain set of criteria that, if met, entitled these institutions to a partial refund of the [...]]]></description>
			<content:encoded><![CDATA[<p>I was involved with a project to create a complicated “Fee Credit Calculator” for a large financial institution. The basis of the project was that large institutional clients paid enormous fees for certain mutual fund transactions. There was a certain set of criteria that, if met, entitled these institutions to a partial refund of the fees they paid.</p>
<p>Basically, if the institution purchased enough of a particular mutual fund they would meet what is called a “right of accumulation” threshold and they’d be entitled to a refund. There were several other components of the calculation including the amount of transactions in a given time period, various legal aspects and total fees paid by the institutional client.</p>
<p>Although the data was always present, the process had long been a tedious manual process that was strictly linear to the number of clients they had. The more business they generated, the more people they were required to hire to process these calculations.</p>
<p>There were also the obvious inefficiencies involving manual calculations, training, lack of productivity, etc. These calculations were complicated and involved several different financial aspects &#8211; all of which users relied on MS Excel to calculate. The project was initially conceived as a web project, but that required the development team to write (from scratch) the financial calculations that Excel already provided. After much discussion, we agreed to write a VSTO Excel solution.</p>
<p>This is a classic example of a problem that needs a VSTO solution:</p>
<ul>
<li> Excel already contained the necessary formulas.</li>
<li> The end users were familiar and comfortable working with Excel.</li>
<li> VSTO allowed a more rapid development environment than starting from scratch.</li>
<li> Existing logic and formulas could be easily re-used in the solution.</li>
</ul>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=52&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/fee-credit-calculator-need-for-a-vsto-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB MazeMan</title>
		<link>http://www.hobbub.com/vba-vb-vsto/vb-mazeman/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/vb-mazeman/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 21:09:42 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/2007/11/03/vb-mazeman/</guid>
		<description><![CDATA[I put this &#8220;Visual Basic MazeMan&#8221; application together for a job interview once upon a time. The job was bogus and I could never bring myself to look at the code again. The requirements have changed &#8211; specifically saving data in binary format &#8211; as opposed to text if you are using this for any projects. Good Luck.
Download [...]]]></description>
			<content:encoded><![CDATA[<p>I put this &#8220;Visual Basic MazeMan&#8221; application together for a job interview once upon a time. The job was bogus and I could never bring myself to look at the code again. The requirements have changed &#8211; specifically saving data in binary format &#8211; as opposed to text if you are using this for any projects. Good Luck.</p>
<p>Download here: <a href="http://www.hobbub.com/downloads/MazeMan.zip">Visual Basic 6.0 MazeMan</a></p>
<p>Here&#8217;s a snippet of a form.</p>
<p>VERSION 5.00<br />
Begin VB.Form frmAbout<br />
   Caption         =   &#8220;About MazeMan v. 1.0&#8243;<br />
   ClientHeight    =   3195<br />
   ClientLeft      =   60<br />
   ClientTop       =   345<br />
   ClientWidth     =   4680<br />
   LinkTopic       =   &#8220;Form1&#8243;<br />
   MaxButton       =   0   &#8216;False<br />
   MinButton       =   0   &#8216;False<br />
   ScaleHeight     =   3195<br />
   ScaleWidth      =   4680<br />
   StartUpPosition =   3  &#8216;Windows Default<br />
   Begin VB.CommandButton cmdClose<br />
      Caption         =   &#8220;Close&#8221;<br />
      Height          =   375<br />
      Left            =   3000<br />
      TabIndex        =   2<br />
      Top             =   2640<br />
      Width           =   1335<br />
   End<br />
   Begin VB.Label lblCompany<br />
      Caption         =   &#8220;Company&#8221;<br />
      Height          =   495<br />
      Left            =   480<br />
      TabIndex        =   1<br />
      Top             =   960<br />
      Width           =   3015<br />
   End<br />
   Begin VB.Label lblTitle<br />
      Caption         =   &#8220;Title&#8221;<br />
      Height          =   375<br />
      Left            =   480<br />
      TabIndex        =   0<br />
      Top             =   240<br />
      Width           =   2895<br />
   End<br />
End<br />
Attribute VB_Name = &#8220;frmAbout&#8221;<br />
Attribute VB_GlobalNameSpace = False<br />
Attribute VB_Creatable = False<br />
Attribute VB_PredeclaredId = True<br />
Attribute VB_Exposed = False<br />
Option Explicit</p>
<p>Private Sub cmdClose_Click()<br />
Unload Me<br />
End Sub</p>
<p>Private Sub Form_Load()<br />
Me.lblTitle.Caption = App.Title<br />
Me.lblCompany.Caption = App.CompanyName<br />
End Sub</p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=51&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/vb-mazeman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three Types of VBA Errors</title>
		<link>http://www.hobbub.com/vba-vb-vsto/three-types-of-vba-errors/</link>
		<comments>http://www.hobbub.com/vba-vb-vsto/three-types-of-vba-errors/#comments</comments>
		<pubDate>Tue, 31 Jul 2007 06:32:57 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[VBA/VSTO]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/2007/07/31/three-types-of-vba-errors/</guid>
		<description><![CDATA[Generally, there are three types of errors that you will encounter when you are writing code: syntax errors, logic errors, and run-time errors. Each type of error requires a different means of troubleshooting. Following is a brief description of each type of error.
Syntax Errors
Let’s start with the easiest type of program error to deal with, [...]]]></description>
			<content:encoded><![CDATA[<p><font face="Times New Roman" size="3">Generally, there are three types of errors that you will encounter when you are writing code: syntax errors, logic errors, and run-time errors. Each type of error requires a different means of troubleshooting. Following is a brief description of each type of error.</font></p>
<p><font face="Times New Roman" size="3" /><font face="Times New Roman" size="3"><strong><font face="Times New Roman" size="4">Syntax Errors</font></strong></p>
<p><font face="Times New Roman" size="3">Let’s start with the easiest type of program error to deal with, the syntax error. A syntax error occurs when your code is written improperly. An example would be a misspelled or missing variable or keyword:</font></p>
<p><font face="Times New Roman" size="2">Dim strName as</font></p>
<p><font face="Times New Roman" size="3">Obviously, an essential piece of code is missing in the statement: the data type. A correct statement would read:</font></p>
<p><font face="Times New Roman" size="2">Dim strName as String</font></p>
<p><font face="Times New Roman" size="3">The key to eliminating syntax errors is to use the Option Explicit statement in every module. Option Explicit will require that all variables are explicitly declared in your project. Explicitly declaring your variables is important for ­several reasons. Simple misspellings in a variable name can cause unwanted behavior and data loss. When working with databases, corrupt data can be entered without any error ever being generated.</font></p>
<div><strong><font face="Times New Roman" size="3">Note:</font></strong></div>
<p><font size="3"><font face="Times New Roman">VBA treats a misspelled variable as just another variable. For example,<br />
</font></font><font face="Times New Roman" size="2">lPayment  = 7,224.45</font></p>
<p><font face="Times New Roman" size="2">Me.txtBalance.Value = lPaymint</font></p>
<div><font size="3"><font face="Times New Roman">The variable lPayment on the second line is misspelled. VBA won’t recognize the misspelling if Option Explicit isn’t turned on, and it will assume that you want it to create a new variable (variant by default). As a result the text box will be updated with an Empty value instead of the desired value of $7,224.45.<br />
</font></font></div>
<p><font face="Times New Roman" size="3">Another important reason to use explicit variable declaration is to optimize your project. By default, undeclared variables use the variant data type. This data type may use significantly more memory than you intend for the variable’s purpose. For example, you may want to use a byte variable in your code. Bytes occupy 1 byte of memory space. If you didn’t explicitly declare the variable, it would be initialized as a variant even though it would only hold 1 byte of data. This means that you’d be using up 16 times the memory you actually need.</font></p>
<p><font face="Times New Roman" size="3">Remember, you can also use the VBE to force variable declaration. Simply select Tools | Options and go to the Editor tab. Once you’re there you can turn Require Variable Declaration on. This will insert Option Explicit at the top of each new module; however, it will not update your existing modules. Go back into your project and insert Option Explicit in any modules you have previously created.</font></p>
<div><strong><font face="Times New Roman" size="3">Note:</font></strong></div>
<div><font face="Times New Roman" size="3">VBA doesn’t allow the same degree of customization as VB as far as compiler settings are concerned. However, there are still some optimizations available. In the VBE, select Tools | Options and go to the General tab. Here you will find a Compile On Demand option. If this is checked, your project should run faster because modules will not be compiled until they are loaded for execution.</font></div>
<p><font face="Times New Roman" size="3">Also on the General tab is a Background Compile option. This option allows the computer to compile your project in the background while the computer is idle. Selecting the Background Compile option can slightly improve the run-time speed of your project (Compile On Demand must also be enabled to use this feature). </font></p>
<div><strong><font face="Times New Roman" size="3">Caution:</font></strong></div>
<div><font face="Times New Roman" size="3">As a final measure of caution, you should always compile your project before it is distributed. This will ensure that all syntax errors have been found. A frequent problem is that your code will refer to a control on a form that has been deleted. If you don’t compile the program ahead of time, you’ll be running to desktops and moving your program’s execution point to the next line of code, or worse, you’ll be the author of the dreaded “AllUser” e-mail informing people there is a problem and instructing them to stay out of the template, document, spreadsheet, or whatever. The process is very simple; just go to the Debug menu and choose Compile Project. </font></div>
<p><strong><font face="Times New Roman" size="4">Logic Errors</font></strong></p>
<p><font face="Times New Roman" size="3">Logic errors occur when your code doesn’t respond the way you intended. Perhaps your logic is unsound, or the program may flow in a different manner than you intended. The best way to check these errors is to manually step through your code using Watch windows. This can be especially tricky when using a series of UserForms—make sure you understand the call stack.</font></p>
<div><strong><font face="Times New Roman" size="3">Tip:</font></strong></div>
<div><font face="Times New Roman" size="3">If you are using a series of UserForms, do not place any code after you call the Show method of the next UserForm. Your program’s execution will always resolve back through the call stack and could produce unexpected results.</font></div>
<p><strong><font face="Times New Roman" size="4">Run-Time Errors</font></strong></p>
<p><font face="Times New Roman" size="3">You cannot avoid run-time errors. However, you can plan for them. Planning for run-time errors involves developing an error handler. The Developer’s Edition of Office 2000 includes a VBA Error Handler add-in that makes working with your error handler easier. Although, we’ll briefly discuss this add-in toward the end of the chapter, we’ll assume you are working in the normal Office environment and discuss how you can implement error handling without this add-in.</font></p>
<p></font></p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=46&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/vba-vb-vsto/three-types-of-vba-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBA Error Handling</title>
		<link>http://www.hobbub.com/uncategorized/vba-error-handling/</link>
		<comments>http://www.hobbub.com/uncategorized/vba-error-handling/#comments</comments>
		<pubDate>Sun, 31 Dec 2006 06:31:10 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VBA/VSTO]]></category>

		<guid isPermaLink="false">http://www.hobbub.com/2006/12/31/vba-error-handling/</guid>
		<description><![CDATA[In a perfect world, there wouldn’t be a need for VBA error handling code at all. The reality is that it doesn’t matter how careful you are when you write your code; undoubtedly, you will have errors. If an application doesn’t handle errors in a professional manner, users will become frustrated, even if the application [...]]]></description>
			<content:encoded><![CDATA[<p>In a perfect world, there wouldn’t be a need for VBA error handling code at all. The reality is that it doesn’t matter how careful you are when you write your code; undoubtedly, you will have errors. If an application doesn’t handle errors in a professional manner, users will become frustrated, even if the application is very refined.\</p>
<p>The Microsoft Office products provide the option to debug code on the fly. This can be either a blessing or a disaster waiting to happen. If you’re in a large organization using Office 2000, you might find yourself frequently running to users’ desks and debugging code right at their desktops. Obviously, this isn’t the preferred manner of handling a project deployment, but if you are doing extensive Office 2000 development, you’ll probably run into this.<br />
A comprehensive error handler can provide feedback to you as a developer and help you understand where the application is breaking down. Keep in mind that any error messages displayed to an end user should be clear and concise. They should also explain exactly what steps the user should take. If they are going to lose information, let them know in the error message (this will save you from being the one to tell them).<br />
Sometimes errors are referred to as bugs. Bugs can be anything from a mistake in the functionality provided (undocumented features) to a coding error that breaks execution of the program from which you cannot recover. Hopefully, you will be conscious of the possibility of bugs and code appropriately. This means that you will try to avoid losing a user’s data should the program crash. There will always be instances where data cannot be recovered, but you should try to minimize both the number of these occurrences as well as the amount of data that is lost.</p>
<p>Debugging is the process of locating bugs in your application and fixing them. VBA provides several tools to help analyze how your application operates. These debugging tools are very powerful when used correctly. Frequently, a programmer finds one or two very rudimentary ways of debugging an application and tries to work them into his debugging arsenal. This is okay in the beginning, but you should always strive to find the most efficient way of debugging your code.</p>
<img src="http://www.hobbub.com/?ak_action=api_record_view&id=45&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hobbub.com/uncategorized/vba-error-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
