<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>vba &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/vba/</link>
	<description>Feed of posts on WordPress.com tagged "vba"</description>
	<pubDate>Sun, 07 Sep 2008 07:45:51 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[The Harsh Taskmaster]]></title>
<link>http://geekcomedyhour.wordpress.com/?p=477</link>
<pubDate>Thu, 04 Sep 2008 12:00:10 +0000</pubDate>
<dc:creator>Afterburner</dc:creator>
<guid>http://geekcomedyhour.wordpress.com/?p=477</guid>
<description><![CDATA[* AB tries to get Creative(tm) with some error trapping
AB: Can&#8217;t quite pull it off.
* AB runs]]></description>
<content:encoded><![CDATA[<p><b>* AB</b> tries to get Creative(tm) with some error trapping<br />
<b>AB:</b> Can't quite pull it off.<br />
<b>* AB</b> runs with the "On Error Abort" option instead<br />
<b>AB:</b> (And, thus, creating an error-handling process that would annoy me personally if I ran into it with any frequency.)<br />
<b>shodan:</b> What, end the program if anything goes wrong?<br />
<b>shodan:</b> Yeah, that'd get annoying<br />
<b>AB:</b> Well.<br />
<b>AB:</b> End the program if the user makes stupid choices.<br />
<b>AB:</b> PICK 1ST CHEMICAL:<br />
<b>AB:</b> &#60;user picks a chemical&#62;<br />
<b>AB:</b> PICK 2nd CHEMICAL:<br />
<b>AB:</b> &#60;user picks the same chemical again&#62;<br />
<b>AB:</b> [BUZZER]<br />
<b>AB:</b> &#60;program aborts&#62;<br />
<b>AB:</b> Only without the buzzer.<br />
<b>AB:</b> But I'd add one if I could.</p>
<p>--------</p>
<p><b>shodan:</b> . o O ( * user picks the same chemical again.  &#60;program&#62; NO YOU FOOL! )<br />
 <b>* AB</b> snerks and changes his error message to "YOU'VE PICKED THE SAME CHEMICAL TWICE!  YOU FOOL!  YOU'VE DOOMED US ALL!"<br />
 <b>AB:</b> Man.<br />
<b>AB:</b> That would be a great generic windows error message.<br />
<b>AB:</b> * User does something innocuous in Windows<br />
<b>AB:</b> &#60;Windows&#62; *ding* FOOL!  YOU'VE DOOMED US ALL!  [OKAY]<br />
<b>shodan:</b> heh<br />
<b>AB:</b> &#60;User&#62; !!!!!!!!<br />
<b>AB:</b> * User runs out into the street, wearing only his underwear, and doesn't turn up again until somewhere in the middle of Kansas</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Listbox MultiSelection]]></title>
<link>http://dvassil.wordpress.com/2008/09/04/121/</link>
<pubDate>Thu, 04 Sep 2008 10:44:20 +0000</pubDate>
<dc:creator>dvassil</dc:creator>
<guid>http://dvassil.wordpress.com/2008/09/04/121/</guid>
<description><![CDATA[Αφορμή για το συγκεκριμένο post ήταν ένα ερώτημα για τη χ]]></description>
<content:encoded><![CDATA[<p>Αφορμή για το συγκεκριμένο post ήταν ένα <a title="List box population (freestuff.gr)" href="http://www.freestuff.gr/forums/viewtopic.php?t=38210" target="_blank">ερώτημα για τη χρήση των listboxes στο freestuff.gr</a>. Αν και το list box στο αρχικό ερώτημα δεν χρειαζόταν παρά single selection, οπότε μπορούσε ο προγραμματιστής να πάρει την τιμή από το property <code>Value</code>, δίνοντας μια απλή λύση, τέθηκε ένα δεύτερο πολύ πιο ενδιαφέρον ερώτημα σχετικά με το πως θα μπορούσε να χρησιμοποιηθεί muti-selection και με πως θα μπορούσαν να αποθηκεύονται/φορτώνονται οι επιλογές.</p>
<p>Μία λύση προτάθηκε από τον ίδιο που έθεσε το ερώτημα:</p>
<blockquote><p>Να αποθηκεύονται οι επιλεγμένοι indexes σε ένα comma separated values string (csv για συντομία). Με ποιόν άλλον τρόπο όμως θα μπορούσε να αποθηκεύονται οι επιλογές;</p></blockquote>
<p>Πρίν 1-2 χρόνια που είχα χρειαστεί κάτι αντίστοιχο είχα αποφύγει τα csv strings γιατί ήταν πολύ δύστροπα αφού απαιτούσαν μεγάλη προσοχή στη διαχείριση τους, αλλά κυρίως επειδή είναι ευαίσθητα στον τύπο των δεδομένων. Με τα νούμερα τα πάνε σχετικά καλά, αλλά με string values; Αν περιέχουν "περίεργους χαρακτήρες" όπως εισαγωγικά, τελείες, κόμματα, αλλαγές γραμμών... Αστα να πάνε, άμα είναι να σου βγάλουν την πίστη, να μένει το βύσινο!</p>
<p>Οπότε μια απάντηση που μου φαίνεται προφανής, αφού για μία (1) εγγραφή μπορείς να έχεις πολλές (Ν) επιλογές, είναι: Σε κάποιον άλλο πίνακα συνδεδεμένο πρός τον πρώτο με σχέση 1-Ν.</p>
<p>Finito!... ...σχεδόν!</p>
<p>Η ουσία του post δεν είναι τόσο το που αποθηκεύονται οι επιλογές, αν είναι csv, πίνακας, blog object, ή οτιδήποτε άλλο, αλλά το τι είναι αυτό που θα αποθηκεύσεις.</p>
<p>Αυτό που διάβασα και χτύπησε το "καμπανάκι" είναι το εξής:</p>
<blockquote><p>...οι <strong>επιλεγμένοι indexes</strong> σε...</p></blockquote>
<p>Την λίστα με τους επιλεγμένους indexes μπορούμε να τους πάρουμε από το property <code>ItemsSelected</code> το οποίο επιστρέφει ένα collection με αυτούς. Είναι όμως <span style="text-decoration:underline;">Μέγα λάθος!</span> Δεν ενδιαφέρουν οι indexes (το οποίο πρακτικά σημαίνει η σειρά εμφάνισης) των επιλογών, αλλά ποιές είναι οι επιλεγμένες τιμές του bound column του ListBox. Το γιατί θα το δείξω χρησιμοποιώντας ένα παράδειγμα παρακάτω. Ενημερωτικά απλώς να αναφέρω ότι τις selected values μπορούμε να τις πάρουμε σε VB κάπως έτσι:<br />
<a name="c1"></a></p>
<pre>'
'Εύρεση επιλεγμένων τιμών σε ένα Listbox
'
Dim item As Variant

For Each item In Control.ItemsSelected
    Debug.Print Control.ItemData(item)
Next item</pre>
<h3>Να διαπιστώσουμε που φαίνεται το λάθος.</h3>
<p>Εστω ότι έχουμε τον πίνακα <code>t1(id: text primary key, descr: text)</code> με τιμές:</p>
<pre>"ΚΑ", "ΚΑΦΕΔΕΣ"
"ΑΝ", "ΑΝΑΨΥΚΤΙΚΑ"
"ΧΥ", "ΧΥΜΟΙ"</pre>
<p>Τα εμφανίζουμε στο listbox, (φέρνουμε τα δεδομένα από τη βάση μας χωρίς να ορίσουμε κάποια ταξινόμηση, οπότε χρησιμοποιείται το id που είναι primary key). Το αποτέλεσμα είναι κάτι τέτοιο:</p>
<pre>"ΑΝΑΨΥΚΤΙΚΑ"
"ΚΑΦΕΔΕΣ"
"ΧΥΜΟΙ"</pre>
<p>Επιλέγουμε τα δύο τελευταία (οπότε θα δημιουργηθεί το string "1,2" που περιέχει τους indexes των δύο επιλογών) και το αποθηκεύουμε σε ένα csv string.<br />
Κλέινουμε τη φόρμα, την ξανανοίγουμε, διαβάζουμε το csv και επιλέγονται τα items με indexes 1 και 2 οπότε φαίνονται στο listbox επιλεγμένα και τα δύο! Το αποτέλεσμα είναι κάτι τέτοιο:</p>
<pre>"ΑΝΑΨΥΚΤΙΚΑ"
"ΚΑΦΕΔΕΣ" (επιλεγμένο)
"ΧΥΜΟΙ" (επιλεγμένο)</pre>
<p>Κλείνουμε τη φόρμα και προσθέτουμε στον πίνακα t1 και τις εγγραφές:</p>
<pre>"ΒΟ", "ΒΟΥΤΗΜΑΤΑ"
"ΝΕ", "ΝΕΡΑ"
"ΠΟ", "ΠΟΤΑ"
"ΦΑ", "ΦΑΓΗΤΑ"
"ΓΛ", "ΓΛΥΚΑ"</pre>
<p>Ανοίγουμε τη φόρμα, διαβάζουμε το csv και επιλέγονται τα items με indexes 1 και 2, και βλέπουμε τα εξής στο listbox:</p>
<pre>"ΑΝΑΨΥΚΤΙΚΑ"
"ΒΟΥΤΗΜΑΤΑ" (επιλεγμένο)
"ΓΛΥΚΑ" (επιλεγμένο)
"ΚΑΦΕΔΕΣ"
"ΝΕΡΑ"
"ΠΟΤΑ"
"ΦΑΓΗΤΑ"
"ΧΥΜΟΙ"</pre>
<p>Ωπα! Κάτι πήγε στραβά! Είχαμε επιλέξει "ΚΑΦΕΔΕΣ" και "ΧΥΜΟΙ" (και που να το θυμόμαστε ειδικά μετά από καιρό), αλλά εμφανίζεται ΒΟΥΤΗΜΑΤΑ και ΓΛΥΚΑ, γιατί εξαρτόμαστε από τη σειρά εμφάνισης (η οποία δεν μας εγγυάται κανένας ότι δεν θα αλλάξει) και όχι από τις τιμές.</p>
<h3>Τι θα ήταν σωστότερο;</h3>
<p>Οταν πάμε να δημιουργήσουμε το csv string να χρησιμοποιήσουμε τον κώδικα<a href="#c1">[1]</a> που βρίσκει τις επιλεγμένες τιμές του listbox, που θα μας δημιουργήσει το string "ΚΑ,ΧΥ", και όταν φορτώνουμε το csv να ψάχνουμε ποιά items έχουν bounded values "ΚΑ" και "ΧΥ" και αφού πάρουμε τον αντίστοιχο index να τα επιλέξουμε με <code>Control.Selected(index) = True</code></p>
<p>Βέβαια, επειδή ο διάβολος έχει πολλά ποδάρια, να υπενθυμίσουμε ότι μιλάμε για multiselection. Αν κάποιος πάει να τα χρησιμοποιήσει και δεν δουλεύει όπως πρέπει, ας κάνει τον κόπο να ελέγξει δύο πράγματα για το Listbox:</p>
<ol>
<li>είναι multiselect και</li>
<li>δεν είναι Locked!</li>
</ol>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Opening A Workbook]]></title>
<link>http://excelling.wordpress.com/?p=20</link>
<pubDate>Sat, 30 Aug 2008 14:58:50 +0000</pubDate>
<dc:creator>parkercpa</dc:creator>
<guid>http://excelling.wordpress.com/?p=20</guid>
<description><![CDATA[Last week I talked about adding a  new workbook using VBA.  This week I want to discuss opening a  ]]></description>
<content:encoded><![CDATA[<p>Last week I talked about <a href="../2008/08/22/adding-a-new-workbook/">adding a  new workbook </a>using VBA.  This week I want to discuss <em>opening</em> a  workbook via VBA. This is one that I use every day and find useful. In my case I  use this when I dump data out of my accounting software and want to add it to an  existing spreadsheet that I use to analyize and accumulate that data. It is one  simple line of  code:</p>
<p>[sourcecode language='vb']Workbooks.Open("C:\SomeFolder\SomeSubFolder\YourFile.xls")[/sourcecode]</p>
<p>It  doesn't get much simpler than that. But it is not unusual for spreadsheets to  have more than one worksheet.  If you saved "YourFile.xls" when you were viewing  sheet2, then it will open on sheet2.  But what if the data you want to view  and/or manipulate is on sheet1?  Well unless you specifically tell VBA to  manipulate sheet1 it will execute the code on whatever sheet it opens to. So it  is always a good practice to tell VBA to select the sheet you want. You would do  so by using the following code:</p>
<p>[sourcecode language='vb']Worksheets(1).Activate[/sourcecode]</p>
<p>Now  although that is pretty straight forward, it does require a little further  explanation. When you tell VBA to activate worksheets(1) what you are  specifically saying is that you want to activate the first worksheet in the  workbook <em>regardless of what it is named</em>.  It could be named sheet4, but  if it is the sheet furthest to the left it is worksheets(1) to VBA. So what do  you do if you want to make sure it actually selects sheet1 or maybe a sheet that  you've named Data?</p>
<p>Then you would change the above line of code to  this:</p>
<p>[sourcecode language='vb']Worksheets("Sheet1").Activate[/sourcecode]</p>
<p>Instead of using the index  number <span style="font-family:Courier;">(1)</span> you simply put the name of the sheet in  quotes inside the parenthesis.</p>
<p>Another tweak to this that I have not  personally used is that instead of using the word <span style="font-family:Courier;">Worksheets</span> you can use the word <span style="font-family:Courier;">Sheets</span>. The difference between the two is that <span style="font-family:Courier;">Sheets</span> includes all sheets in the workbook which would  include any chart sheets or dialog sheets.  Conversely if you were to use  either:</p>
<p>[sourcecode language='vb']Charts(1).Activate<br />
DialogSheets(1).Activate[/sourcecode]</p>
<p>It would  function the same as <span style="font-family:Courier;">Worksheets(1).Activate</span> above.  It  would select the very first chart sheet or dialog sheet in the workbook  regardless of its name.  So if you wanted to make sure you selected the correct  chart when you opened up your YourFile.xls you would want to follow the same  principle and write it this way:</p>
<p>[sourcecode language='vb']Charts("Chart1").Activate[/sourcecode]</p>
<p>Once  you've gotten this, you are well on your way to adding data to an existing  spreadsheet or retreiving data from an existing spreadsheet and using VBA to do  the heavy lifting for you.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Using the Dictionary object in VBA]]></title>
<link>http://415systems.wordpress.com/?p=24</link>
<pubDate>Sat, 30 Aug 2008 01:01:11 +0000</pubDate>
<dc:creator>415systems</dc:creator>
<guid>http://415systems.wordpress.com/?p=24</guid>
<description><![CDATA[The Dictionary object is a little-known hash-table implementation that ships as part of the Microsof]]></description>
<content:encoded><![CDATA[<p>The Dictionary object is a little-known hash-table implementation that ships as part of the Microsoft Scripting Runtime DLL. You'll need to add a reference to Microsoft Scripting, but once you've done this using the Dictionary is easy.</p>
<p>The Dictionary is useful when:</p>
<ul>
<li>You need a dynamic array without the programming overhead of managing the array.</li>
<li>You need to store key/value pairs - for example, server names and IP addresses or employee names and email addresses.</li>
<li>You need to search rapidly within large in-memory lists and do not want the performance hit of looping through data structures.</li>
</ul>
<p>Unlike arrays, which force you to use ordinal references (0,1,2,3, etc.), a dictionary's key can be any combination of characters, the only requirement being that the keys must be unique. Also unlike arrays, requesting a value using a key doesn't require iteration through the data structure, making searching for known values very fast.</p>
<p>In the example below, we create 200,001 collection objects and add them to a dictonary using the keys 0-200000. Then we retrieve the collection with the key 200,000. It's important to note that under the hood the key parameter of the Dictionary object is overloaded, so the datatype is important - a key of 1 is different to "1", and to demonstrate this the second retrieval in the example will fail.</p>
<pre>Public Function DictionaryTest()
    Dim dct As Dictionary, i As Long, o As Collection
    Set dct = New Dictionary
    ' Create 200,000 collection objects and store them in the dictionary...
    For i = 0 To 200000
        Set o = New Collection
        dct.Add i, o
    Next i
    ' Check if a key exists and if so show the size of the related collection (always 0 in this test)
    If dct.Exists(200000) Then
        Debug.Print dct(200000).Count
    Else
        Debug.Print "Cannot find 200000."
    End If
    If dct.Exists("200000") Then
        Debug.Print dct(200000).Count
    Else
        Debug.Print "Cannot find '200000'."
    End If
    Set dct = Nothing

End Function</pre>
<p>Dictionaries are a highly useful VBA resource that offer more methods than collections and more flexibility than arrays, especially since the value types can be mixed within one dictionary.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[vamos a lo básico]]></title>
<link>http://arcobjects.wordpress.com/?p=3</link>
<pubDate>Fri, 29 Aug 2008 19:51:14 +0000</pubDate>
<dc:creator>Julio</dc:creator>
<guid>http://arcobjects.wordpress.com/?p=3</guid>
<description><![CDATA[Hola a todos los interesados en compartir y aprender a programar con ArcObjects. Como ustedes saben,]]></description>
<content:encoded><![CDATA[<p>Hola a todos los interesados en compartir y aprender a programar con ArcObjects. Como ustedes saben, ArcObjects es un mundo bastante oscuro y distante para los usuarios de sistemas de información geográfica, especialmente para los que no tienen fundamentos de programación. Es por esta razón que el blog se inclinará a presentar, desde código muy básico hasta código muy complejo de forma paulatina - todo esto desarrollado con <em>Visual Basic for Applications</em> (VBA) - para mostrar la funcionalidad que podemos llegar a tener mediante la utilización de esta herramienta.</p>
<p class="MsoNormal">
<p class="MsoNormal">En próximas entradas empezaremos con conceptos un poco más firmes sobre la temática de ArcObjects. Si alguien conoce links de sitios web que nos puedan ayudar a profundizar sobre los conceptos básicos de ArcObjects, por favor no se olviden de dejar su comentario.</p>
<p class="MsoNormal">
<p class="MsoNormal">Empecemos!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Excel WorkSheet Password]]></title>
<link>http://deshnilesh.wordpress.com/?p=164</link>
<pubDate>Fri, 29 Aug 2008 09:12:05 +0000</pubDate>
<dc:creator>deshnilesh</dc:creator>
<guid>http://deshnilesh.wordpress.com/?p=164</guid>
<description><![CDATA[I again forgot my password for a excel worksheet and then begin mission to crack it :). Fortunately ]]></description>
<content:encoded><![CDATA[<p>I again forgot my password for a excel worksheet and then begin mission to crack it :). Fortunately I cam across this code which will give you a alternate password. There is more <a href="http://www.mrexcel.com/forum/showthread.php?t=35417" target="_blank">detail discussion</a> about how it works on the site, I am copying the code here for my reference so in future if I need it again I won't have to search again.</p>
<table border="0" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<p class="MsoNormal">
<p class="MsoNormal"><span style="color:#000080;"><span style="font-size:10pt;font-family:&#34;color:navy;">Sub</span></span><span style="font-size:10pt;font-family:&#34;color:#339966;"> <span style="color:#000000;">PasswordBreaker()</span></span><span style="font-size:10pt;font-family:&#34;color:#339966;"><br />
<span style="color:#008000;"> 'by Bob McCormick on NG: microsoft.public.excel.misc</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
<span style="color:#008000;">'on 22 May 2001.</span><span style="color:#008000;"><br />
</span> <span style="color:#008000;">'Breaks worksheet password protection.</span><br />
<span style="color:#000080;"> Dim</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i <span style="color:navy;">As Integer</span>, j <span style="color:navy;">As Integer</span>, k <span style="color:navy;">As Integer</span><br />
<span style="color:#000080;"> Dim</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> l <span style="color:navy;">As Integer</span>, m <span style="color:navy;">As Integer</span>, n <span style="color:navy;">As Integer</span><br />
<span style="color:#000080;"> Dim</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i1 <span style="color:navy;">As Integer</span>, i2 <span style="color:navy;">As Integer</span>, i3 <span style="color:navy;">As Integer</span><br />
<span style="color:#000080;"> Dim</span></span><span style="font-size:10pt;font-family:&#34;"> i4 <span style="color:navy;">As Integer</span>, i5 <span style="color:navy;">As Integer</span>, i6 <span style="color:navy;">As Integer</span></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:&#34;color:navy;"><span style="color:#000080;">On Error Resume Next</span><br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> j = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> k = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> l = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> m = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i1 = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i2 = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i3 = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i4 = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"><span style="color:#000080;"> </span>i5 = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"> i6 = 65 <span style="color:navy;">To</span> 66<br />
<span style="color:#000080;"> For</span></span><span style="font-size:10pt;font-family:&#34;"> n = 32 <span style="color:navy;">To</span> 126</span><span style="font-size:10pt;font-family:&#34;">ActiveSheet.Unprotect Chr(i) &#38; Chr(j) &#38; Chr(k) &#38; _</span><span style="font-size:10pt;font-family:&#34;"><br />
Chr(l) &#38; Chr(m) &#38; Chr(i1) &#38; Chr(i2) &#38; Chr(i3) _</span><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
<span style="color:#000000;">&#38; Chr(i4) &#38; Chr(i5) &#38; Chr(i6) &#38; Chr(n)</span><br />
<span style="color:#000080;"> If</span></span><span style="font-size:10pt;font-family:&#34;"><span style="color:#000080;"> </span>ActiveSheet.ProtectContents = <span style="color:navy;">False Then<br />
</span>MsgBox "One usable password is " &#38; Chr(i) &#38; Chr(j) _</span><span style="font-size:10pt;font-family:&#34;"><br />
&#38; Chr(k) &#38; Chr(l) &#38; Chr(m) &#38; Chr(i1) &#38; Chr(i2) _</span><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
<span style="color:#000000;">&#38; Chr(i3) &#38; Chr(i4) &#38; Chr(i5) &#38; Chr(i6) &#38; Chr(n)</span></span><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
<span style="color:#000080;"> Exit Sub</span></span><span style="color:#000080;"><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
End If</span><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
Next</span><span style="font-size:10pt;font-family:&#34;color:navy;"><br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
Next<br />
End Sub</span></span></td>
</tr>
</tbody>
</table>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Control Menu and Toolbars and quick keys in Word VBA]]></title>
<link>http://alexcrossley.wordpress.com/?p=157</link>
<pubDate>Fri, 29 Aug 2008 06:32:55 +0000</pubDate>
<dc:creator>alexcrossley</dc:creator>
<guid>http://alexcrossley.wordpress.com/?p=157</guid>
<description><![CDATA[Example code&#8230;
Dim myToolbar As CommandBar
Dim myTool As Object
Dim myMenu As Object
Dim objKey]]></description>
<content:encoded><![CDATA[<p>Example code...</p>
<p>Dim myToolbar As CommandBar<br />
Dim myTool As Object<br />
Dim myMenu As Object<br />
Dim objKeyBindings As KeyBindings</p>
<p>''  Toolbars<br />
Set myToolbar = Application.CommandBars("Standard")<br />
myToolbar.Visible = True<br />
Set myTool = myToolbar.Controls(6)<br />
myTool.Visible = True</p>
<p>Set myToolbar = Application.CommandBars("Formatting")<br />
myToolbar.Visible = True</p>
<p>Set myToolbar = Application.CommandBars("Numbering")<br />
myToolbar.Visible = True</p>
<p>''  Menus<br />
Set myToolbar = Application.CommandBars("Menu Bar")<br />
Set myTool = myToolbar.Controls(1)</p>
<p>Set myMenu = myTool.Controls(8)<br />
myTool.Visible = False<br />
Set myMenu = myTool.Controls(19)<br />
myTool.Visible = True</p>
<p>''  Keys<br />
Set objKeyBindings = Application.KeyBindings<br />
objKeyBindings.Add KeyCategory:=wdKeyCategoryMacro, Command:="MenuPrint", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyP)            'Ctrl P Print</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Open a web page from Visual Basic VBA in iexplore]]></title>
<link>http://alexcrossley.wordpress.com/?p=155</link>
<pubDate>Fri, 29 Aug 2008 06:30:23 +0000</pubDate>
<dc:creator>alexcrossley</dc:creator>
<guid>http://alexcrossley.wordpress.com/?p=155</guid>
<description><![CDATA[Here I have a form with 2 controls of interest, an OK and a help button.  The idea is when you clic]]></description>
<content:encoded><![CDATA[<p>Here I have a form with 2 controls of interest, an OK and a help button.  The idea is when you click help, in this example, we open up Google.  [if only I could impliment this as a help soultion for users]</p>
<p>Private Sub cmdHelp_Click()<br />
Dim strLink As String<br />
strLink = "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.google.com.au"<br />
Shell (strLink), vbMaximizedFocus<br />
Call cmdOK_Click<br />
End Sub</p>
<p>Private Sub cmdOK_Click()<br />
Me.Hide<br />
End Sub</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Solving simultaneous equations]]></title>
<link>http://newtonexcelbach.wordpress.com/?p=299</link>
<pubDate>Wed, 27 Aug 2008 13:42:00 +0000</pubDate>
<dc:creator>dougaj4</dc:creator>
<guid>http://newtonexcelbach.wordpress.com/?p=299</guid>
<description><![CDATA[Solving a series of simultaneous equations is a task frequently required in engineering and scientif]]></description>
<content:encoded><![CDATA[<p>Solving a series of simultaneous equations is a task frequently required in engineering and scientific analysis.  Excel provides the tools to perform this task quickly and easily, but the procedure is not documented in the on-line help (so far as I can see).</p>
<p>The procedure is:</p>
<ul>
<li>Enter the coefficients of the equations as a square matrix, that is an nxn array, where n is the number of equations, and enter the values of the equations in an n rowed column.</li>
<li>invert the matrix, using the MINVERSE() function</li>
<li>Multiply the inverted matrix by the result values column, using the MMULT() function.  The result is an array formula containing the n solutions to the equations.  The MMULT function can operate directly on the output from the MINVERSE function, as shown in the screenshot below.  Note that the results are an array formula, and which must be entered with ctrl-shift-enter.</li>
</ul>
<p>The screenshot also shows two User Defined Functions that perform the same task:</p>
<p>SSOLVE() simply calls MINVERSE and MMULT.</p>
<p>GESOLVE() solves the equations by Gaussian Elimination, thus allowing much bigger systems of equations to be solved than can be handled by the built in functions.  I could not find a clear statement of the maximum capacity of the Excel buit-in matrix functions, but testing shows that it is something less than 160 equations in Excel 2000, and something greater than 160 in Excel 2007.</p>
<p>Right click to download the spreadsheet <a href="http://interactiveds.com.au/software/Simultaneous.xls">Simultaneous.xls</a></p>
[caption id="attachment_302" align="aligncenter" width="467" caption="Simultaneous.xls screenshot"]<a href="http://newtonexcelbach.files.wordpress.com/2008/08/simultaneous.jpg"><img class="size-large wp-image-302" src="http://newtonexcelbach.wordpress.com/files/2008/08/simultaneous.jpg?w=467" alt="Simultaneous.xls screenshot" width="467" height="408" /></a>[/caption]
]]></content:encoded>
</item>
<item>
<title><![CDATA[Concatenate a range of unknown size with custom delimeter]]></title>
<link>http://415systems.wordpress.com/?p=20</link>
<pubDate>Tue, 26 Aug 2008 21:35:41 +0000</pubDate>
<dc:creator>415systems</dc:creator>
<guid>http://415systems.wordpress.com/?p=20</guid>
<description><![CDATA[If you manage lists of email addresses in either Excel or a database, the time will come when you wa]]></description>
<content:encoded><![CDATA[<p>If you manage lists of email addresses in either Excel or a database, the time will come when you want to send out a mass email to all your contacts and you have an issue in transforming the rows or table of data into email-client format (usually one long string of addresses separated by a comma or semi-colon).</p>
<p>I have seen people attempt this manually, or build incredibly long CONCATENATE structures (=CONCATENATE(A1,",",A2,",".... etc.) so I built this custom function that makes the procedure very easy. Cut and paste the code below into a module in your spreadsheet:<br></p>
<pre>Option Explicit</pre>
<pre>Public Function ConcatenateRange(ByVal oRange As Range, Optional sDelim As String) As String</pre>
<pre>&#160;&#160;&#160; Dim oCell As Range<br>&#160;&#160;&#160; For Each oCell In Application.Intersect(oRange, oRange.Parent.UsedRange)</pre>
<pre>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ConcatenateRange = ConcatenateRange &#38; sDelim &#38; CStr(oCell.Value)</pre>
<pre>&#160;&#160;&#160; Next oCell</pre>
<pre>&#160;&#160;&#160; ConcatenateRange = Mid(ConcatenateRange, Len(sDelim) + 1)</pre>
<pre>End Function</pre>
<p>Now if you have a range of data items in column A, for example, and the list is an unknown length, so you can simply call =CONCATENATERANGE(A:A,",") and this will produce a comma-separated string of the used part of the range. You can change the delimiter to any character(s) you desire.<br></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Capturing non-ASCII keys in Microsoft Access]]></title>
<link>http://415systems.wordpress.com/2008/08/26/capturing-non-ascii-keys-in-microsoft-access/</link>
<pubDate>Tue, 26 Aug 2008 18:09:00 +0000</pubDate>
<dc:creator>415systems</dc:creator>
<guid>http://415systems.wordpress.com/2008/08/26/capturing-non-ascii-keys-in-microsoft-access/</guid>
<description><![CDATA[Recently, the need arose to capture function keys in a form and suppress Access&#8217; response (eg.]]></description>
<content:encoded><![CDATA[<p>Recently, the need arose to capture function keys in a form and suppress Access' response (eg. pressing F1 would not invoke the Help feature), and there is a surprisingly easy solution. You can also capture all the non-ASCII keys (shift, insert, alt, etc.) and choose to either 'listen' or prevent Access from handling these. This was used in a point-of-sale project, where function keys are used to change the mode of the application.</p>
<p>To do this, simply change the 'Key Preview' property of the form to 'Yes' and then use the 'Form_KeyDown' event in the form's VBA module. The two parameters, KeyCode and Shift, indicate which keys are being pressed and if any of the character-set shifts (ie. shift, control, alt) are being held. This fires for <em>every</em> key, so you will need to parse the values for KeyCodes that interest you. Resetting the KeyCode parameter to zero will effectively cancel the keypress.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Importing Web Data into a Spreadsheet Dynamically]]></title>
<link>http://415systems.wordpress.com/2008/08/26/importing-web-data-into-a-spreadsheet-dynamically/</link>
<pubDate>Tue, 26 Aug 2008 16:22:00 +0000</pubDate>
<dc:creator>415systems</dc:creator>
<guid>http://415systems.wordpress.com/2008/08/26/importing-web-data-into-a-spreadsheet-dynamically/</guid>
<description><![CDATA[A very useful feature introduced in Excel 97 enables you to webscrape a site and import defined area]]></description>
<content:encoded><![CDATA[<p>A very useful feature introduced in Excel 97 enables you to webscrape a site and import defined areas into a spreadsheet. There are a variety of situations where this could be useful:</p>
<p>- Utilizing real-time financial market data.<br />
- Importing weather forecasts.<br />
- Checking if your ads are appearing in a search engine.<br />
- Viewing the latest headlines.</p>
<p><img style="display:block;width:402px;height:168px;text-align:center;margin:0 auto 10px;" src="http://2.bp.blogspot.com/_irXJ5r-q9Gk/SLQ5PuYd3eI/AAAAAAAAAB0/NYD4xhmut1c/s320/WebScrape.jpg" border="0" alt="" width="415" height="195" /></p>
<p>To import data from a webpage:</p>
<ol>
<li>Click Data --&#62; Get External Date --&#62; From Web.</li>
<li>Enter the URL to scrape (eg. <a href="http://news.google.com/">http://news.google.com/</a>).</li>
<li>Click the yellow areas for the page divisions you wish to import.</li>
<li>Click 'Options..." to specify how HTML formatting and PRE are handled.</li>
</ol>
<p>After importing, right click anywhere in the imported block and click 'Data Range Properties' to specify how often the page should be refreshed (the minimum time is 1 minute). <a href="http://www.415systems.com/examples/WebData.xlsm">Click here for a spreadsheet that demonstrates the four sample uses above</a>.</p>
<p>Unfortunately, there is no specific event that is fired when your web query refreshes. However, you can use the Worksheet_Change event and verify that the target range parameter matches the cell area for your web query (see the sample spreadsheet's VBA module for details). Frequently this is required since there is usually some parsing required from the results.</p>
<p>If the source data of your query is dynamic (eg. you a looking up an area code driven by user-generated data), it is simple to use VBA to generate the web query results:</p>
<p><span style="font-family:courier new;">Dim sSearchTerm As String<br />
sSearchTerm = Cells(2, 2)   ' For example...<br />
</span><span style="font-family:courier new;"><br />
With ActiveSheet.QueryTables.Add(Connection:= _<br />
"URL;http://www.google.com/search?hl=en&#38;q=" &#38; sSearchTerm, Destination:=Range("$B$4"))<br />
</span><span style="font-family:courier new;"> .WebSelectionType = xlEntirePage<br />
.WebFormatting = xlWebFormattingNone<br />
.WebPreFormattedTextToColumns = True<br />
.WebConsecutiveDelimitersAsOne = True<br />
.WebSingleBlockTextImport = False<br />
.WebDisableDateRecognition = False<br />
.WebDisableRedirections = False<br />
.Refresh<br />
</span><span style="font-family:courier new;"> .BackgroundQuery:=False<br />
End With</span></p>
<p>Although web queries lack the full power available by using MSXML or WinSock to retrieve web data, for simple queries they provide a very rapid and reliable way to scrape a webpage.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[VisualBoyAdvance: Unsupported VisualBoyAdvance save game version 9]]></title>
<link>http://howtoefren.wordpress.com/?p=538</link>
<pubDate>Tue, 26 Aug 2008 07:01:30 +0000</pubDate>
<dc:creator>efrenefren</dc:creator>
<guid>http://howtoefren.wordpress.com/?p=538</guid>
<description><![CDATA[Unsupported VisualBoyAdvance save game version 9 (Click to enlarge)
It happenned to me when I transf]]></description>
<content:encoded><![CDATA[[caption id="" align="alignnone" width="240" caption="Unsupported VisualBoyAdvance save game version 9 (Click to enlarge)"]<a title="VisualBoyAdvance - Unsupported VIsualBoyAdvance save game version 9 by efrenefren, on Flickr" href="http://www.flickr.com/photos/efrenefren/2799309078/"><img src="http://farm4.static.flickr.com/3108/2799309078_9d458ba78d_m.jpg" alt="VisualBoyAdvance - Unsupported VIsualBoyAdvance save game version 9" width="240" height="182" /></a>[/caption]
<p>It happenned to me when I transferred my save states from an <a title="Ubuntu" href="http://www.ubuntu.com/">Ubuntu</a> Linux laptop to a Windows laptop. The main reason for this is because the save states from my Ubuntu laptop was created by VisualBoyAdvance 1.8beta3 version and on the Windows laptop was VisualBoyAdvance 1.7.2.</p>
<p>To fix this just install the <a title="Visual Boy Advance" href="http://vba.ngemu.com/downloads/VisualBoyAdvance-1.8.0-beta3.zip">VisualBoyAdvance 1.8beta3 version</a></p>
<p>OR</p>
<p>If you want to use to still use whatever version of Visual Boy Advance you have in both laptops make sure that you save in-game and transfer the <span style="border-bottom:thin dashed;" title="file with the .sav extension">battery files</span> instead.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Word Add-IN to Persist a Dictionary Object as XML]]></title>
<link>http://networknerd.wordpress.com/?p=8</link>
<pubDate>Sun, 24 Aug 2008 05:50:37 +0000</pubDate>
<dc:creator>networknerd</dc:creator>
<guid>http://networknerd.wordpress.com/?p=8</guid>
<description><![CDATA[A friend of my eldest child asked for some advice on creating a database. Seems that she was a keen ]]></description>
<content:encoded><![CDATA[<p>A friend of my eldest child asked for some advice on creating a database. Seems that she was a keen fiction writer and needed to keep track of the meanings of the words she'd invented.</p>
<p>A Database would be overkill for the job and it seemed like a good opportunity to practice using XML and VBA.  Two scripting.dictionary objects could be used to hold the data in memory while creating the story. One for fiction to english translation and the other to perform reverse lookups. The data would be retrieved from the xml file when the add-in loaded and saved when it was unloaded.</p>
<p>It turned out to be a pretty simple job and the code is shown below. Four simple functions were required: add a word, delete a word, lookup and reverse lookup.<!--more--></p>
<blockquote><p><strong>Dictionary Code Module</strong></p>
<p>Option Explicit<br />
Public objDict, objRDict As Variant<br />
Public Const MYDOCUMENTS As Integer = 16<br />
Public Const XML_ATTR_KEY As String = "Word"<br />
Public Const XML_ATTR_VALUE As String = "Meaning"<br />
Public Const XML_ELEMENT_OUTER As String = "Dictionary"<br />
Public Const XML_ELEMENT_INNER As String = "Entry"<br />
Public Const STR_INDENT As String = vbCrLf &#38; "    "<br />
Public Const XPATH As String = "/Dictionary/Entry"<br />
Public Const STR_DICT_FILENAME As String = "EDictionary.xml"</p>
<p>Sub initDict()</p>
<p>Set objDict = CreateObject("Scripting.Dictionary")<br />
Set objRDict = CreateObject("Scripting.Dictionary")</p>
<p>End Sub</p>
<p>Function GetMyDocuments() As String<br />
Dim WSHShell As Object<br />
Set WSHShell = CreateObject("Wscript.Shell")<br />
GetMyDocuments = WSHShell.SpecialFolders(MYDOCUMENTS)<br />
Set WSHShell = Nothing<br />
End Function</p>
<p>Sub addword()<br />
Dim strFWord, strEWord As String<br />
Dim frmTemp As Variant<br />
Dim dlgResult As Integer</p>
<p>If (Not Selection Is Nothing) Then<br />
strFWord = Trim(Selection.Words(1).Text)<br />
End If<br />
Set frmTemp = New frmLookup<br />
frmTemp.mkAddEntry (strFWord)<br />
Do<br />
frmTemp.Show<br />
If frmTemp.dlgResult = vbCancel Then<br />
Unload frmTemp<br />
Set frmTemp = Nothing<br />
Exit Sub<br />
End If<br />
strFWord = frmTemp.Fictionword()<br />
strEWord = frmTemp.Englishword()<br />
If (strFWord &#60;&#62; "" And _<br />
strEWord &#60;&#62; "" And _<br />
Not objDict.Exists(strFWord)) Then<br />
objDict.Add strFWord, strEWord<br />
objRDict.Add strEWord, strFWord<br />
Exit Do<br />
Else<br />
MsgBox "Word already exists in Dictionary or is blank.", vbExclamation<br />
End If<br />
Loop<br />
End Sub</p>
<p>Sub delword()<br />
Dim strFWord, strEWord As String<br />
Dim frmTemp As Variant<br />
Dim dlgResult As Integer</p>
<p>If (Not Selection Is Nothing) Then<br />
strFWord = Trim(Selection.Words(1).Text)<br />
End If<br />
Set frmTemp = New frmLookup<br />
frmTemp.mkDelEntry (strFWord)<br />
Do<br />
frmTemp.Show<br />
If frmTemp.dlgResult = vbCancel Then<br />
Unload frmTemp<br />
Set frmTemp = Nothing<br />
Exit Sub<br />
End If<br />
strFWord = frmTemp.Fictionword()<br />
strEWord = frmTemp.Englishword()<br />
If (strFWord &#60;&#62; "" And objDict.Exists(strFWord)) Then<br />
strEWord = objDict.Item(strFWord)<br />
objDict.Remove strFWord<br />
If objRDict.Exists(strEWord) Then<br />
objRDict.Remove strEWord<br />
End If<br />
Exit Do<br />
Else<br />
MsgBox "Word not found in Dictionary.", vbExclamation<br />
End If<br />
Loop<br />
End Sub</p>
<p>Sub rlookup()<br />
Dim strFWord, strEWord, strMsg As String<br />
Dim frmTemp As Variant<br />
Dim dlgResult As Integer</p>
<p>If (Not Selection Is Nothing) Then<br />
strEWord = Trim(Selection.Words(1).Text)<br />
End If<br />
Set frmTemp = New frmLookup<br />
frmTemp.mkRLookup (strEWord)<br />
Do<br />
frmTemp.Show<br />
If frmTemp.dlgResult = vbCancel Then<br />
Unload frmTemp<br />
Set frmTemp = Nothing<br />
Exit Sub<br />
End If<br />
strEWord = frmTemp.Englishword()<br />
If (strEWord &#60;&#62; "" And objRDict.Exists(strEWord)) Then<br />
strFWord = objRDict.Item(strEWord)<br />
frmTemp.FictionText = strFWord<br />
Else<br />
MsgBox "Word not found in Dictionary.", vbExclamation<br />
End If<br />
Loop</p>
<p>End Sub</p>
<p>Sub lookup()<br />
Dim strFWord, strEWord, strMsg As String<br />
Dim frmTemp As Variant<br />
Dim dlgResult As Integer</p>
<p>If (Not Selection Is Nothing) Then<br />
strFWord = Trim(Selection.Words(1).Text)<br />
End If<br />
Set frmTemp = New frmLookup<br />
frmTemp.mkLookup (strFWord)<br />
Do<br />
frmTemp.Show<br />
If frmTemp.dlgResult = vbCancel Then<br />
Unload frmTemp<br />
Set frmTemp = Nothing<br />
Exit Sub<br />
End If<br />
strFWord = frmTemp.Fictionword()<br />
If (strFWord &#60;&#62; "" And objDict.Exists(strFWord)) Then<br />
strEWord = objDict.Item(strFWord)<br />
frmTemp.EnglishText = strEWord<br />
Else<br />
MsgBox "Word not found in Dictionary.", vbExclamation<br />
End If<br />
Loop</p>
<p>End Sub<br />
Sub dsave()<br />
Dim strFileName As String</p>
<p>strFileName = GetMyDocuments() &#38; "\" &#38; STR_DICT_FILENAME<br />
savedictionary (strFileName)<br />
End Sub<br />
Sub dload()<br />
Dim strFileName As String</p>
<p>strFileName = GetMyDocuments() &#38; "\" &#38; STR_DICT_FILENAME<br />
loaddictionary (strFileName)</p>
<p>End Sub</p>
<p>Sub savedictionary(strFileName)<br />
Dim xmlDoc As DOMDocument<br />
Dim key As Variant<br />
Dim dict, entry, word, meaning, node As IXMLDOMNode</p>
<p>Set xmlDoc = New DOMDocument<br />
Set node = xmlDoc.createNode(NODE_ELEMENT, XML_ELEMENT_OUTER, "")<br />
Set dict = xmlDoc.appendChild(node)<br />
For Each key In objDict.keys()<br />
Set node = xmlDoc.createTextNode(STR_INDENT)<br />
dict.appendChild node<br />
Set node = xmlDoc.createNode(NODE_ELEMENT, XML_ELEMENT_INNER, "")<br />
Set entry = dict.appendChild(node)<br />
Set word = xmlDoc.createAttribute(XML_ATTR_KEY)<br />
word.Text = key<br />
entry.Attributes.setNamedItem word<br />
Set meaning = xmlDoc.createAttribute(XML_ATTR_VALUE)<br />
meaning.Text = objDict.Item(key)<br />
entry.Attributes.setNamedItem meaning<br />
Next key<br />
Set node = xmlDoc.createTextNode(vbCrLf)<br />
dict.appendChild node<br />
xmlDoc.Save strFileName</p>
<p>End Sub</p>
<p>Sub loaddictionary(strFileName)<br />
Dim xmlDoc As DOMDocument<br />
Dim entries As IXMLDOMNodeList<br />
Dim entry, word, meaning As IXMLDOMNode<br />
Dim strWord, strMeaning As String</p>
<p>initDict<br />
Set xmlDoc = New DOMDocument ' Create xmldoc and load the specified xml file<br />
xmlDoc.Load (strFileName)<br />
If xmlDoc.documentElement Is Nothing Then<br />
MsgBox "Error loading xml dictionary file: " _<br />
&#38; vbCrLf &#38; strFileName &#38; vbCrLf _<br />
&#38; "File not found or failed to parse." _<br />
, vbCritical<br />
Exit Sub<br />
End If<br />
' Select all dictionary entries from the xml file<br />
Set entries = xmlDoc.selectNodes(XPATH)<br />
' For each entry check for and extract the attributes<br />
For Each entry In entries<br />
Set word = entry.Attributes.getNamedItem(XML_ATTR_KEY)<br />
Set meaning = entry.Attributes.getNamedItem(XML_ATTR_VALUE)<br />
If (Not (word Is Nothing) And Not (meaning Is Nothing)) Then<br />
strWord = word.Text<br />
strMeaning = meaning.Text<br />
If (Not objDict.Exists(strWord)) Then<br />
objDict.Add strWord, strMeaning         'add to dictionary<br />
If (Not objRDict.Exists(strMeaning)) Then<br />
objRDict.Add strMeaning, strWord    'add to rev. dictionary<br />
End If<br />
End If<br />
End If<br />
Next entry<br />
End Sub</p>
<p><strong>Autoexec Module</strong></p>
<p>Option Explicit<br />
Sub main()<br />
Dim cmdEbar As CommandBar<br />
Dim ctlPopup As CommandBarPopup<br />
Dim ctlButton As CommandBarButton<br />
Dim i As Integer</p>
<p>initDict ' initialise the in memory dictionary structures<br />
dload    ' load previously persisted dictionary xml file</p>
<p>Set cmdEbar = Application.CommandBars.Add("E's Toolbar", , , True)<br />
With cmdEbar<br />
.Visible = True<br />
.Position = msoBarTop<br />
End With<br />
For i = 1 To 4<br />
Set ctlButton = cmdEbar.Controls.Add(Type:=msoControlButton)<br />
With ctlButton<br />
.Visible = True<br />
.Style = msoButtonIcon<br />
Select Case i<br />
Case 1<br />
.FaceId = 2006<br />
.OnAction = "addword"<br />
.TooltipText = "Add word to dictionary"<br />
Case 2<br />
.OnAction = "delword"<br />
.TooltipText = "Delete word from dictionary"<br />
.FaceId = 2005<br />
Case 3<br />
.OnAction = "lookup"<br />
.TooltipText = "Lookup Fiction -&#62; English"<br />
.FaceId = 229<br />
Case 4<br />
.OnAction = "rlookup"<br />
.TooltipText = "Lookup English -&#62; Fiction"<br />
.FaceId = 1820<br />
Case Else<br />
End Select<br />
End With<br />
Next i<br />
End Sub</p>
<p>Sub main()<br />
Application.CommandBars("E's Toolbar").Delete ' lose the toolbar<br />
Call dsave  ' persist the dictionary to an XML file<br />
End Sub</p></blockquote>
<blockquote><p><strong>Form Code Module</strong></p></blockquote>
<p>Option Explicit<br />
Private intResult As Integer</p>
<p>Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)<br />
If CloseMode = vbFormControlMenu Then<br />
Cancel = True           ' cancel this close event to prevent automation errors<br />
cmdCancel_Click     ' and start our approved shutdown sequence<br />
End If<br />
End Sub</p>
<p>Property Get dlgResult() As Integer<br />
dlgResult = intResult<br />
End Property</p>
<p>Private Sub cmdCancel_Click()<br />
intResult = vbCancel<br />
Me.Hide<br />
End Sub</p>
<p>Private Sub cmdOk_Click()<br />
intResult = vbOK<br />
Me.Hide<br />
End Sub</p>
<p>Public Sub mkLookup(strWord As String)<br />
txtEnglish.Enabled = False<br />
txtEnglish.BackColor = &#38;H80000011<br />
txtFiction.Text = strWord<br />
End Sub</p>
<p>Public Sub mkRLookup(strWord As String)<br />
txtFiction.Enabled = False<br />
txtFiction.BackColor = &#38;H80000011<br />
Me.Caption = "Reverse " &#38; Me.Caption<br />
txtEnglish.Text = strWord<br />
End Sub</p>
<p>Public Sub mkAddEntry(strWord As String)<br />
Me.Caption = "Add Dictionary Entry"<br />
txtFiction.Text = strWord<br />
End Sub</p>
<p>Public Sub mkDelEntry(strWord As String)<br />
Me.Caption = "Remove Dictionary Entry"<br />
txtEnglish.Enabled = False<br />
txtEnglish.BackColor = &#38;H80000011<br />
txtFiction.Text = strWord<br />
End Sub</p>
<p>Property Get Englishword() As String<br />
Dim Englishwords As Variant<br />
Englishwords = Split(Trim(txtEnglish.Text)) ' remove leading spaces and get words<br />
If (UBound(Englishwords) &#60;&#62; -1) Then<br />
Englishword = LCase(Englishwords(0))<br />
Else<br />
Englishword = ""<br />
End If<br />
End Property</p>
<p>Property Get Fictionword() As String<br />
Dim Fictionwords As Variant<br />
Fictionwords = Split(Trim(txtFiction.Text)) ' remove leading spaces and get words<br />
Fictionword = Fictionwords(0)<br />
If (UBound(Fictionwords) &#60;&#62; -1) Then<br />
Fictionword = LCase(Fictionwords(0))<br />
Else<br />
Fictionword = ""<br />
End If<br />
End Property</p>
<p>Property Let EnglishText(strWord)<br />
txtEnglish.Text = strWord<br />
End Property</p>
<p>Property Let FictionText(strWord)<br />
txtFiction.Text = strWord<br />
End Property</p>
<p><strong>The Form</strong></p>
<p><img class="alignnone size-full wp-image-9" src="http://networknerd.wordpress.com/files/2008/08/frm.jpg" alt="" width="318" height="236" /></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Why AB Doesn't Program Computers For A Living]]></title>
<link>http://geekcomedyhour.wordpress.com/?p=386</link>
<pubDate>Fri, 22 Aug 2008 12:00:48 +0000</pubDate>
<dc:creator>Afterburner</dc:creator>
<guid>http://geekcomedyhour.wordpress.com/?p=386</guid>
<description><![CDATA[* AB tries to get VBA to conform to his whims
shodan: . o O ( VBA? )
shodan: Oh, visual basic?
AB: Y]]></description>
<content:encoded><![CDATA[<p><b>* AB</b> tries to get VBA to conform to his whims<br />
<b>shodan:</b> . o O ( VBA? )<br />
<b>shodan:</b> Oh, visual basic?<br />
<b>AB:</b> Yeah.<br />
<b>AB:</b> Microsoft implementation of it for their Office products.<br />
<b>AB:</b> &#60;VBA&#62; Argument not optional!  &#60;AB&#62; That's not an argument!  That's just the automatic gainsaying of...</p>
<p>--------</p>
<p><b>* AB</b> runs afoul of one of the programming concepts he has the most difficulty with<br />
<b>AB:</b> Passing variables from one subroutine to another.<br />
<b>* AB</b> tries passing the variables explicitly<br />
<b>* AB</b> (not surprisingly) gets an error<br />
<b>AB:</b> Ah-HAH<br />
<b>* AB</b> gets that working<br />
<b>AB:</b> w00t<br />
<b>* AB</b> does The Dance(tm)<br />
<b>* shodan</b> cheers!<br />
<b>shodan:</b> What'd ya have to do?<br />
<b>AB:</b> Forgot to hand the variables off to the main function when I called it.<br />
<b>AB:</b> Call $FUNCTION_NAME<br />
<b>AB:</b> Sposed to be "Call $FUNCTION_NAME (list of passed variables)"<br />
<b>shodan:</b> Hm.<br />
<b>AB:</b> As with most of my code, it's ugly, but it works.<br />
<b>shodan:</b> If you're doing it that way, it doesn't /sound/ like a global variable<br />
<b>AB:</b> Yeah.<br />
<b>AB:</b> It isn't.<br />
<b>AB:</b> Really.<br />
<b>shodan:</b> But I can kinda see how it works.<br />
<b>AB:</b> I'm declaring 'em locally within the first procedure.<br />
<b>AB:</b> (And I'm also declaring them publically in the main procedure.  I expect the world to implode any moment now.)<br />
<b>AB:</b> Nah.  I'm just not grokking the syntax.<br />
<b>AB:</b> There's a way to do it.<br />
<b>AB:</b> Where you just make the one public declaration.<br />
<b>AB:</b> Thought I remembered how I'd done it in the past.<br />
<b>AB:</b> But NOOOooooOoOOOOOOo<br />
<b>* AB</b> sets his brane on fire<br />
<b>shodan:</b> Doncha need that?<br />
<b>AB:</b> Not doing me a lot of good right now.<br />
<b>* AB</b> passes his variables to a COMPLETELY DIFFERENT procedure<br />
<b>shodan:</b> That'll show 'em.</p>
<p>--------</p>
<p><b>AB:</b> Doh<br />
<b>AB:</b> &#60;Assignment instructions&#62; Make sure to do error trapping.  If I enter "asdf" into the box asking for temperature, your program should catch it.<br />
<b>AB:</b> &#60;AB&#62; 'kay<br />
<b>AB:</b> * AB writes an If/Then thingy which features "If IsNumeric($VARIABLE) = False Then..."<br />
<b>AB:</b> * AB tests his code by typing random letters in the Temperature box.<br />
<b>AB:</b> &#60;Program&#62; TYPE MISMATCH, PH00L!<br />
<b>shodan:</b> * AB types "mismatch"   &#60;program&#62; Type mismatch  &#60;AB&#62; I just did!</p>
]]></content:encoded>
</item>

</channel>
</rss>
