<?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>Sat, 26 Jul 2008 17:10:17 +0000</pubDate>

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

<item>
<title><![CDATA[Create Access Database via DAO]]></title>
<link>http://socko.wordpress.com/?p=67</link>
<pubDate>Sat, 26 Jul 2008 08:50:59 +0000</pubDate>
<dc:creator>selvavpasupathy</dc:creator>
<guid>http://socko.wordpress.com/?p=67</guid>
<description><![CDATA[by Selva V Pasupathy


Option Explicit
Private myMdbPath As String
Private myMDB As Database
Private]]></description>
<content:encoded><![CDATA[<p>by Selva V Pasupathy<br />
<code>
<pre>
Option Explicit
Private myMdbPath As String
Private myMDB As Database
Private myTableDef As TableDef
Private myIndex As DAO.Index

Sub Create_MDB()
    myMdbPath = ThisWorkbook.Path &#38; "\" &#38; _
                                myMDBName &#38; ".mdb"
    If Dir(myMdbPath)  "" Then Kill myMdbPath

    Set myMDB = CreateDatabase(myMdbPath, dbLangGeneral)

    Set myTableDef = myMDB.CreateTableDef(MyTable)

    With myTableDef
        .Fields.Append .CreateField("ID", dbLong, 4)
        .Fields.Append .CreateField("ACCT", dbText, 14)
   .Fields.Append .CreateField("CII", dbText, 14)
   .Fields.Append .CreateField("STATUS", dbText)
   .Fields.Append .CreateField("DECISION", dbText)
   .Fields.Append .CreateField("RACF", dbText)
   .Fields.Append .CreateField("CONTRACTDATE", dbDate)
   .Fields.Append .CreateField("RECEIPTDATE", dbDate)
   .Fields.Append .CreateField("FOLLOWUPDATE", dbDate)
   .Fields.Append .CreateField("FOLLOWUP_N1", dbText)
   .Fields.Append .CreateField("FOLLOWUP_N2", dbText)
   .Fields.Append .CreateField("DECLIFE", dbText)
   .Fields.Append .CreateField("DECDIS", dbText)
   .Fields.Append .CreateField("REASON", dbText)
   .Fields.Append .CreateField("FIRSTNAME", dbText)
   .Fields.Append .CreateField("LASTNAME", dbText)
   .Fields.Append .CreateField("ADDLINE1", dbText)
   .Fields.Append .CreateField("ADDLINE2", dbText)
   .Fields.Append .CreateField("CITY", dbText)
   .Fields.Append .CreateField("ST", dbText, 2)
   .Fields.Append .CreateField("ZIP", dbText, 5)

   myTableDef("ID").Attributes = dbAutoIncrField

   Set myIndex = .CreateIndex("ACCT")
   myIndex.Fields.Append myIndex.CreateField("ID", dbLong)

        myIndex.Primary = True
        .Indexes.Append myIndex
    End With

    ' Save Table info
    myMDB.TableDefs.Append myTableDef
    myMDB.Close
End Sub

Private Function myMDBName()
myMDBName = Application.InputBox("Give " &#38;amp: _
     the name of the " &#38; _
     "Access file you want to be saved. ")
End Function
Private Function MyTable()
    MyTable = Application.InputBox("Give " &#38; _
     the name of the " &#38; _
     "Table you want in MDB file. ")
End Function
</pre>
<p></code></p>
<p>For more on Resources, Downloads, &#38;<br />
       Tutorials visit following pages<br />
http://selvavinaygam.googlepages.com<br />
http://socko.350.com</p>
<p>For Feedback and/or comments, please mail me at<br />
s o c k o (at) r e d i f f m a i l (dot) c o m</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Drawing in Excel 5 - Shape List]]></title>
<link>http://newtonexcelbach.wordpress.com/?p=236</link>
<pubDate>Sat, 26 Jul 2008 07:09:43 +0000</pubDate>
<dc:creator>dougaj4</dc:creator>
<guid>http://newtonexcelbach.wordpress.com/?p=236</guid>
<description><![CDATA[Previous Post
For some reason best known to Microsoft, the Excel documentation does not include a gr]]></description>
<content:encoded><![CDATA[<p><a title="Previous post" href="http://newtonexcelbach.wordpress.com/2008/07/15/drawing-in-excel-4/">Previous Post</a></p>
<p>For some reason best known to Microsoft, the Excel documentation does not include a graphic list of shapes with an example of each shape, and the text list they do provide is incomplete. </p>
<p>The file <a title="ShapeList.zip" href="http://members.optushome.com.au/dougjenkins/Software/shapelist.ZIP">shapelist.zip </a></p>
<p>rectifies that omission with an automatically generated table of shapes from number 1 through to 183.<br />
<a href="http://newtonexcelbach.wordpress.com/files/2008/07/shapelist.jpg"><img class="aligncenter size-full wp-image-241" src="http://newtonexcelbach.wordpress.com/files/2008/07/shapelist.jpg" alt="" width="468" height="281" /></a></p>
<p>It also includes examples of how arcs (shape no. 25) work in Excel 2007 and earlier versions.<br />
 <br />
<a href="http://newtonexcelbach.wordpress.com/files/2008/07/shapelist2.jpg"><img class="aligncenter size-full wp-image-240" src="http://newtonexcelbach.wordpress.com/files/2008/07/shapelist2.jpg" alt="" width="468" height="272" /></a></p>
<p>The size and position of arcs are defined with the usual width, height, left, and top properties, but note that the width and height are equal to the arc radius, and the left coordinate is equal to the X value of the arc centre.  The start and end points of the arc are defined with Adjustment(1) and Adjustment(2), and the shape thus defined may be rotated with the Rotation property.  Unfortunately there are significant differences in the way in which these properties are applied in Excel 2007 and earlier versions.</p>
<p>Assuming  an XY coordinate system, with origin at the centre of the arc:</p>
<p>Adjustment(1)  defines the angle of the start of the arc, measured from the X axis.  In Excel 2007 clockwise angles are positive, in earlier versions anti-clockwise is positive.</p>
<p>In both versions an Adjustment(1) value of zero defaults to a starting point on the Y axis, i.e. to -90 degrees in Excel 2007 and 90 degrees in earlier versions.</p>
<p>Adjustment(2) defines the angle of the end of the arc, measured from the X axis, with the same sign convention as adjustment(1).  An adjustment(2) value of zero defines an end point on the X axis, as would be expected, zero values for both adjustments therefore defines an arc between the Y and X axes.</p>
<p>The rotate property rotates the defined shape, with a clockwise rotation being positive in all Excel versions.</p>
<p>In Excel 2007 the shape is rotated about the origin, i.e. the centre of curvature of the arc.  In earlier versions the rotation appears to be about the mid-point of a radial line to the centre of the arc.</p>
<p>For compatibility between versions it seems best to avoid using the Rotation property, and adjust the sign of the adjustment angles according to the version number.</p>
<p>Code to generate an arc and a circle, using values specified in a spreadsheet range, is shown below.  The code checks for the Excel version, and for versions earlier than 2007 (version 12.0) reverses the sign of the arc adjustments, so that the arcs drawn are consistent across versions.</p>
<p><code>Sub Drawshape()</p>
<p>Dim shapeA As Variant, sType As MsoAutoShapeType, sLeft As Single, s_Top As Single, sWidth As Single</p>
<p>Dim sHeight As Single, sRotn As Single, sAdj1 As Single, sAdj2 As Single</p>
<p>Dim shp As Shape, i As Long</p>
<p>For Each shp In ActiveSheet.Shapes</p>
<p>shp.Delete</p>
<p>Next shp</p>
<p>shapeA = Range("shapetab").Value2</p>
<p>i = 1</p>
<p>Do While shapeA(1, i) &#60;&#62; 0</p>
<p>sType = shapeA(1, i)</p>
<p>sLeft = shapeA(2, i)</p>
<p>s_Top = shapeA(3, i)</p>
<p>sWidth = shapeA(4, i)</p>
<p>sHeight = shapeA(5, i)</p>
<p>sRotn = shapeA(6, i)</p>
<p>sAdj1 = shapeA(7, i)</p>
<p>sAdj2 = shapeA(8, i)</p>
<p>If Application.Version &#60; 12 Then</p>
<p>sAdj1 = -sAdj1</p>
<p>sAdj2 = -sAdj2</p>
<p>End If</p>
<p>With ActiveSheet.Shapes</p>
<p>Set shp = .AddShape(sType, sLeft, s_Top, sWidth, sHeight)</p>
<p>End With</p>
<p>With shp</p>
<p>.Rotation = sRotn</p>
<p>If sAdj1 &#60;&#62; 0 Then .Adjustments(1) = sAdj1</p>
<p>If sAdj1 &#60;&#62; 0 Then .Adjustments(2) = sAdj2</p>
<p>.Fill.Visible = msoFalse</p>
<p>End With</p>
<p>i = i + 1</p>
<p>Loop</p>
<p>End Sub</code><br />
 <br />
An example of the shapes generated by this code is shown below:</p>
<p><a href="http://newtonexcelbach.wordpress.com/files/2008/07/arc_circle.jpg"><img class="aligncenter size-medium wp-image-239" src="http://newtonexcelbach.wordpress.com/files/2008/07/arc_circle.jpg?w=198" alt="" width="198" height="300" /></a></p>
<p>Note that "Width" and "Height" values of the circle are double that of the arc, and the "Left" value of the circle is 105 less than that of the arc.</p>
<p> </p>
<p>Use of the "rotation" property in Excel 2007 and earlier versions is illustrated below:</p>
<p> <a href="http://newtonexcelbach.files.wordpress.com/2008/07/rotation2003.jpg"><img class="aligncenter size-medium wp-image-237" src="http://newtonexcelbach.wordpress.com/files/2008/07/rotation2003.jpg?w=300" alt="" width="300" height="212" /></a><a href="http://newtonexcelbach.wordpress.com/files/2008/07/rotation2007.jpg"><img class="aligncenter size-medium wp-image-238" src="http://newtonexcelbach.wordpress.com/files/2008/07/rotation2007.jpg?w=300" alt="" width="300" height="253" /></a></p>
<p> </p>
<p> </p>
<p>Note that the input for these two screen shots was identical.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[VBA ParseName (fullname, type)]]></title>
<link>http://isaohk.wordpress.com/2008/07/22/vba-parsenamefullname-type/</link>
<pubDate>Tue, 22 Jul 2008 04:49:48 +0000</pubDate>
<dc:creator>isaohk</dc:creator>
<guid>http://isaohk.wordpress.com/2008/07/22/vba-parsenamefullname-type/</guid>
<description><![CDATA[Public Enum ExtractType
  vbFirst = 0
  vbLast = 1
End Enum

 

Public Function ParseName(fullnam]]></description>
<content:encoded><![CDATA[<p><span style="font-size:12pt;font-family:Courier New;"><strong><span style="color:#4f81bd;">Public Enum</span> ExtractType</strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong>  vbFirst = <span style="color:#c0504d;">0</span></strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong>  vbLast = <span style="color:#c0504d;">1</span></strong></span></p>
<div><span style="font-size:12pt;color:#4f81bd;font-family:Courier New;"><strong>End Enum</p>
<p></strong></span></div>
<p><span style="font-size:12pt;color:#4f81bd;font-family:Courier New;"> </p>
<p></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong><span style="color:#4f81bd;">Public Function</span> ParseName(fullname <span style="color:#4f81bd;">As</span> String, type <span style="color:#4f81bd;">As</span> ExtractType) <span style="color:#4f81bd;">As</span> String</strong></span></p>
<div><span style="font-size:12pt;font-family:Courier New;"><strong><span style="color:#4f81bd;">  Dim</span> pos, i <span style="color:#4f81bd;">As</span> Integer</strong></span><span style="font-size:12pt;font-family:Courier New;"> </span></div>
<p><span style="font-size:12pt;font-family:Courier New;"><strong>  pos = InStrRev(fullname, " ")</strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong><span style="color:#4f81bd;">  If</span> type = vbFirst <span style="color:#4f81bd;">Then</span></strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong>    ParseName = Right(fullname, Len(fullname) - pos)</strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong><span style="color:#4f81bd;">  Else</span></strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong><span style="color:#4f81bd;">    If</span> type = vbLast <span style="color:#4f81bd;">Then</span></strong></span></p>
<p><span style="font-size:12pt;font-family:Courier New;"><strong>      ParseName = Trim(Left(fullname, pos))</strong></span></p>
<p><span style="font-size:12pt;color:#4f81bd;font-family:Courier New;"><strong>    End If</strong></span></p>
<p><span style="font-size:12pt;color:#4f81bd;font-family:Courier New;"><strong>  End If</strong></span></p>
<p><span style="font-size:12pt;color:#4f81bd;font-family:Courier New;"><strong>End Function</strong></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Newton's Cradle]]></title>
<link>http://newtonexcelbach.wordpress.com/?p=219</link>
<pubDate>Sun, 20 Jul 2008 11:09:01 +0000</pubDate>
<dc:creator>dougaj4</dc:creator>
<guid>http://newtonexcelbach.wordpress.com/?p=219</guid>
<description><![CDATA[Previous animation post
I have added a Newton&#8217;s Cradle animation to the animation file posted ]]></description>
<content:encoded><![CDATA[<p><a title="animation " href="http://newtonexcelbach.wordpress.com/2008/06/22/drawing-in-excel-2/">Previous animation post</a></p>
<p>I have added a Newton's Cradle animation to the animation file posted previously:</p>
<p><a title="Animation" href="http://members.optushome.com.au/dougjenkins/Software/animate.zip">Animation.zip</a></p>
<p><a href="http://newtonexcelbach.files.wordpress.com/2008/07/ncradle1.jpg"><img class="aligncenter size-full wp-image-222" src="http://newtonexcelbach.wordpress.com/files/2008/07/ncradle1.jpg" alt="" width="468" height="272" /></a></p>
<p>The animation finds the correct period for the input string length and starting angle, and displays the movement of the balls in real time.<a href="http://newtonexcelbach.files.wordpress.com/2008/07/ncradle.jpg"></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Mail archiving in Outlook/Exchange with vba]]></title>
<link>http://dhalicious.wordpress.com/?p=12</link>
<pubDate>Tue, 15 Jul 2008 13:18:12 +0000</pubDate>
<dc:creator>dhalicious</dc:creator>
<guid>http://dhalicious.wordpress.com/?p=12</guid>
<description><![CDATA[I like structure in my emails and I like vba so I decided
to make a custom rule that could not be ac]]></description>
<content:encoded><![CDATA[<p>I like structure in my emails and I like vba so I decided<br />
to make a custom rule that could not be achieved easily<br />
with the standard rules feature in outlook...</p>
<p>This code will check my inbox every time I start outlook for emails older than 7 days.<br />
If found it will place emails from corporate collegues into one rootfolder named after<br />
my company. Then it will create a subfolder with the senders name (if not allready existing)<br />
and put the older email in that folder. So I have all mails sorted<br />
in their own maps by user. All external mails are placed in another rootfolder<br />
called "extern" and then subfolders are created based on senders domain name.</p>
<p>How to install:<br />
1. Make 2 subfolders in your inbox (eg. MyCompany, External)<br />
2. Open Visual Basic Editor (ALT+F11)<br />
3. In the project explorer, expand "Microsoft Office Outlook Project" and doubleclick<br />
"ThisOutlookSession" to edit it's code.<br />
4. Copy and paste the code below and change the 4 variables:<br />
- <strong>strCompany</strong> = the folder you created in your inbox for corporate emails.<br />
- <strong>strExternaly</strong> = the folder you created in your inbox for external emails.<br />
- <strong>intAge</strong> = the age a mail should be before moving it (in days).<br />
- <strong>strDSN</strong> = general DSN for your company. Change "COMPANY".<br />
(if you don't know what DSN is, ask your system administrator)<br />
5. Save and quit.<br />
6. Start Outlook, have some patience and see how<br />
every mail older then (in this case) 7 days is nicely organized!</p>
<blockquote><p>Dim x, i As Integer</p>
<p>Private Sub Application_Startup()<br />
On Error Resume Next</p>
<p>    Dim intDays As Integer<br />
    Dim strCompany, strExternaly, strDSN As String<br />
    'MODIFY HERE:<br />
    strCompany = "Aliplast"<br />
    strExternaly = "Extern"<br />
    strDSN = "/O=ALIPLAST/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN="<br />
    intAge = 7</p>
<p>    Dim strID As String<br />
    Dim objNS As Outlook.NameSpace<br />
   <br />
    Dim m As Outlook.MailItem<br />
    Dim oInboxItem As Outlook.MailItem<br />
   <br />
    Dim fInbox As MAPIFolder<br />
    Dim fCompany As MAPIFolder<br />
    Dim fExtern As MAPIFolder<br />
    Dim fFolder As MAPIFolder<br />
   <br />
    Set objNS = Application.GetNamespace("MAPI")<br />
    Set fInbox = objNS.GetDefaultFolder(olFolderInbox)<br />
    Set fCompany = fInbox.Folders(strCompany)<br />
    Set fExtern = fInbox.Folders(strExternaly)<br />
   <br />
    'm.UserProperties<br />
    For Each oInboxItem In fInbox.Items<br />
        strID = oInboxItem.EntryID<br />
        If strID = "" Then<br />
            ' MsgBox strID<br />
        Else<br />
            Set m = objNS.GetItemFromID(strID)<br />
            ' MsgBox m.ReceivedTime &#60; vbCrLf &#38; Now() - intAge<br />
            If m.ReceivedTime &#60; Now() - intAge Then<br />
                If InStr(m.SenderEmailAddress, "/" &#38; StripDSN(strDSN)) Or InStr(m.SenderEmailAddress, "aliplast") Then<br />
                    ' Exchange mail<br />
                    ' MsgBox m.SenderEmailAddress<br />
                    fFolder = fAliplast.Folders(Exchange(m.SenderEmailAddress))<br />
                    fAliplast.Folders.Add (Exchange(m.SenderEmailAddress))<br />
                    m.Move fAliplast.Folders(Exchange(m.SenderEmailAddress))<br />
                Else<br />
                    ' Externe mail<br />
                    ' MsgBox Domein(m.SenderEmailAddress)<br />
                    fFolder = fExtern.Folders(Domein(m.SenderEmailAddress))<br />
                    fExtern.Folders.Add (Domein(m.SenderEmailAddress))<br />
                    m.Move fExtern.Folders(Domein(m.SenderEmailAddress))<br />
                End If<br />
            End If<br />
        End If<br />
    Next</p>
<p>    Set m = Nothing<br />
    Set objNS = Nothing<br />
End Sub</p>
<p>Public Function Domein(email As String) As String<br />
x = 1<br />
Do<br />
x = x + 1<br />
Loop Until Mid(email, x, 1) = "@"<br />
Domein = Mid(email, x + 1, (Len(email) - x) + 1)<br />
End Function</p>
<p>Public Function Exchange(email As String) As String<br />
Exchange = StrConv(Replace(Replace(email, strDSN, ""), ".", " "), vbProperCase)<br />
End Function</p>
<p>Public Function StripDSN(DSN As String) As String<br />
Dim tmp As String<br />
tmp = ""<br />
x = 1<br />
i = 0<br />
Do<br />
If Mid(DSN, x, 1) = "/" Then<br />
x = x + 1<br />
i = i + 1<br />
Else<br />
tmp = tmp &#38; Mid(DSN, x, 1)<br />
x = x + 1<br />
End If<br />
Loop Until Mid(DSN, x, 1) = "/"<br />
StripDSN = tmp<br />
End Function </p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Drawing in Excel-4]]></title>
<link>http://newtonexcelbach.wordpress.com/?p=209</link>
<pubDate>Tue, 15 Jul 2008 07:44:13 +0000</pubDate>
<dc:creator>dougaj4</dc:creator>
<guid>http://newtonexcelbach.wordpress.com/?p=209</guid>
<description><![CDATA[This post will look in a bit more detail at the methods presented in the previous post.  It would b]]></description>
<content:encoded><![CDATA[<p>This post will look in a bit more detail at the methods presented in the <a title="Previous post" href="http://newtonexcelbach.wordpress.com/2008/07/04/drawing-in-excel-3/">previous post</a>.  It would be a good idea to open the previous post on another tab, or download the example file and open the code in the Visual Basic editor.</p>
<p>For each of the shapes in the example code the shape was added to the "shape collection" (and hence displayed on the active worksheet) with a command of the form, either:</p>
<p>set VariableName = ActiveSheet.Shapes.addShape(parameters)</p>
<p>or</p>
<p>with ActiveSheet.Shapes.addShape(parameters)<br />
.property = PropertySetting<br />
end with</p>
<p>or the similar:</p>
<p>ActiveSheet.Shapes.addShape(parameters).property = PropertySetting</p>
<p>For two of the methods used in the example (AddCurve and AddPolyLine) a different form is allowed; e.g.:</p>
<p>ActiveSheet.Shapes.AddCurve (PointArray)</p>
<p>will add the curve specified by PointArray to the shapes collection.  Note the space between AddCurve and the parameters.  The editor will add the space if necessary for those methods where this form is acceptable, otherwise it will tell you that it is expecting a "=", and one of the forms described earlier must be used.</p>
<p>I have no idea what is the logic (or if there is any logic) behind the way the different methods are handled, but it seems to me best to stick with command forms that will work for all the shape methods.</p>
<p>It can be seen that there are a variety of methods to create simple shapes, for instance a straight line can be created using:</p>
<p>AddLine<br />
AddPolyline (with one segment)<br />
AddShape<br />
ConverttoShape<br />
or even AddCurve</p>
<p>Similarly the dodecahedron can be created with AddPolyline, ConverttoShape or AddShape, but using AddCurve with the same coordinates produces a different shape.</p>
<p>In general I will be using AddLine or AddPolyLine in most cases, with AddShape being used for arcs and circles (or ellipses) or if a regular polygon is required.</p>
<p>The final point concerns the naming of shapes.  Each of the shapes except the dodoecahedron created with the AddPolyline method have been given a name at the time of their creation.  Shapes not explicitly named are given a name consisting of a description followed by a sequence number, such as FreeForm44.  Since the sequence number will increment as shapes are created and deleted it is impossible to know what any given shapes allocated name will be, so if you will need to select a shape using VBA code at any time the shape should be named explicitly at the time of its creation.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Enabling Mouse Scrolling In VBA]]></title>
<link>http://movefirstblog.wordpress.com/?p=33</link>
<pubDate>Mon, 14 Jul 2008 12:48:32 +0000</pubDate>
<dc:creator>movefirstblog</dc:creator>
<guid>http://movefirstblog.wordpress.com/?p=33</guid>
<description><![CDATA[I&#8217;ve just had to set up a new PC and, for a few minutes there, was confused as to why the scro]]></description>
<content:encoded><![CDATA[<p>I've just had to set up a new PC and, for a few minutes there, was confused as to why the scroll wheel did not work in the VBA code window.</p>
<p>Then I remembered that VBA is based on the Microsoft Visual Basic 6 IDE which doesn't include built-in support for the scroll wheel.</p>
<p>After a little searching I found the following article on the Microsoft site: <a title="Enable mouse wheel in VBA" href="http://office.microsoft.com/en-us/access/HA101175901033.aspx" target="_blank">http://office.microsoft.com/en-us/access/HA101175901033.aspx</a><em> (opens in new window)</em></p>
<p>In short, to enable the mouse wheel scrolling behaviour in the VBA window, you must download a package from Microsoft at <a href="http://office.microsoft.com/search/redir.aspx?AssetID=XT101665991033&#38;CTT=5&#38;Origin=HA101175901033" target="_blank">http://office.microsoft.com/search/redir.aspx?AssetID=XT101665991033&#38;CTT=5&#38;Origin=HA101175901033</a> <em> (opens in new window)</em> and then do the following:</p>
<ul>
<li>Run the downloaded executable to extract the files</li>
<li>Add the included DLL to your machine</li>
<li>Register the DLL using RegSvr32</li>
<li>Run the included registry file to add the required elements to your machine's registry (remembering to take a backup of the registry first of course)</li>
<li>Add the MouseWheel Fix to your VBA project using the Add-In manager</li>
</ul>
<p>Now the scroll wheel should work in your VBA code!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Microsoft Access - Handling NULL values with the NZ() function]]></title>
<link>http://movefirstblog.wordpress.com/?p=32</link>
<pubDate>Mon, 14 Jul 2008 12:27:08 +0000</pubDate>
<dc:creator>movefirstblog</dc:creator>
<guid>http://movefirstblog.wordpress.com/?p=32</guid>
<description><![CDATA[In Microsoft Access VBA, as in many other implementations, if we try to evaluate an expression conta]]></description>
<content:encoded><![CDATA[<p>In Microsoft Access VBA, as in many other implementations, if we try to evaluate an expression containing a NULL value the whole expression will return NULL.</p>
<p>For example:<br />
<code><br />
Dim varMyValue as Variant<br />
varMyValue = NULL<br />
MsgBox IsNull(varMyValue + 2)<br />
</code></p>
<p>This will return TRUE.</p>
<p>However, it is often the case that we would like this expression to "ignore" the NULL value and return the value 2.</p>
<p>We can achieve this using the NZ function.</p>
<p>The syntax of this function is as follow:</p>
<p style="padding-left:30px;"><em>Nz(variant, [valueifnull])</em></p>
<p>Thus we could ignore the NULL value and substitute it with 0.</p>
<p>e.g.<br />
<code><br />
Dim varMyValue as Variant<br />
varMyValue = NULL<br />
MsgBox NZ(varMyValue,0) + 2<br />
</code></p>
<p>Here the NULL value is replaced with the value zero and our message box displays the value 2.</p>
<p>We could also use the NZ function in other ways.</p>
<p>If we have a variable containing a string , for example, the country of a purchaser (e.g. UK, US, PL) and we use this to calculate a postage rate for goods sent to this purchase we could use the NZ function in the following way to replace a NULL value with a suitable message or calculation.</p>
<p>e.g.<br />
<code><br />
strPostage = NZ(strCountry,0) ' if we wanted to set the postage value to zero if it is NULL<br />
</code></p>
<p>or<br />
<code><br />
strPostage = NZ(strCountry,"No Country Code Given") ' to maybe use in a MsgBox if strCountry is NULL<br />
</code></p>
<p>We could also use the NZ function in an Access SQL query.</p>
<p><code><br />
SELECT [Surname], [FirstName], [DOB], NZ([Address],"No Address Available")<br />
</code></p>
<p>Note, however, that this function is only available within Access and not within any of the rest of the Office suite. Also, other variants of SQL may not support this function.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Progressive Status Indicators in Excel]]></title>
<link>http://guj800.wordpress.com/?p=42</link>
<pubDate>Thu, 10 Jul 2008 14:23:23 +0000</pubDate>
<dc:creator>J. D. Palmer</dc:creator>
<guid>http://guj800.wordpress.com/?p=42</guid>
<description><![CDATA[This is one of those posts that is really only for my own benefit.  I recently decided to tackle the]]></description>
<content:encoded><![CDATA[<p>This is one of those posts that is really only for my own benefit.  I recently decided to tackle the idea of rather than just putting red, yellow, and green indicator lights on a spreadsheet to indicate how close we were to meeting budget in certain areas, I would programatically allow Excel to determine how "green" or how "red" we were, with yellow in the middle.</p>
<p>So, in other words, if red is RGB(250,0,0), yellow is RGB(250,250,0), and green is RGB(0,250,0), how do we gradually go from red to green depending on how far away from budget we are?  By the way, for those who don't know, the RGB number format is simply three numbers from 0 to 250 that represent how much of each color red, green, and blue the computer ought to use to compose a color.  Adding red light to green light makes yellow light, so RGB(250,250,0) means you want to use pure red and pure green, but no blue in order to get yellow.</p>
<p>My first task was deciding how to measure the distance from budget.  After a lot of calculations, I realized it should simply be how far from 100% of the budget we were.  That leaves a scale of 0 to 100.  At 100, we want to just display green, and at 0 we want red.</p>
<p>My second task was fading from red to green by going through yellow.  My best solution was to split the task in half.  If the actual value was less than 50% of the goal, we would worry about fading from red to yellow (we would only need to mess with the green color).  If the actual value was more than 50%, we would fade from yellow to green (only mess with the red color).  In other words: If  50% of budget, green = 250, red = calculated value.  Blue is always 0.</p>
<p>Since there are 250 steps of color in the RGB scale, but only 125 for each half (red to yellow, yellow to green), then for every percent of budget, we want to add or remove 5 steps of color.</p>
<p>That's all I need to explain, I think, in order to remember this later.  If you have any questions, I will gladly answer them.  What follows are two real-world examples taken straight from my current project. </p>
<p><code>Sub looper()</p>
<p>&#160;&#160;&#160;&#160;Dim mydiff As Double<br />
&#160;&#160;&#160;&#160;Dim i As Integer</p>
<p>&#160;&#160;&#160;&#160;For i = 5 To 10<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;mydiff = (Cells(i, 23) - Cells(i, 24)) / Cells(i, 24)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Call update_indicator("shp" &#38; i - 4, mydiff)<br />
&#160;&#160;&#160;&#160;Next i</p>
<p>End Sub</p>
<p>Sub update_indicator(strShape As String, dblVar As Double)</p>
<p>&#160;&#160;&#160;&#160;Dim intR As Integer<br />
&#160;&#160;&#160;&#160;Dim intG As Integer<br />
&#160;&#160;&#160;&#160;Dim intB As Integer</p>
<p>&#160;&#160;&#160;&#160;intB = 0</p>
<p>&#160;&#160;&#160;&#160;If dblVar &#60; -0.5 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intR = 250<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intG = 250 - (((Abs(dblVar) * 100) - 50) * 5)<br />
&#160;&#160;&#160;&#160;ElseIf dblVar &#60; 0 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intG = 250<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intR = 0 + ((Abs(dblVar) * 100) * 5)<br />
&#160;&#160;&#160;&#160;Else<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intG = 250<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intR = 0<br />
&#160;&#160;&#160;&#160;End If</p>
<p>&#160;&#160;&#160;&#160;ActiveSheet.Shapes(strShape).Select<br />
&#160;&#160;&#160;&#160;Selection.ShapeRange.Fill.ForeColor.RGB = RGB(intR, intG, intB)</p>
<p>End Sub</code></p>
]]></content:encoded>
</item>

</channel>
</rss>
