Wednesday, August 27, 2008

Donor Management Application




I created a nifty donor management application in MS Access 2003. This is a great tool for managing your donor information and to create thank you's etcetera.

If you're interested in getting a copy just email me.


Replace Spaces With Tabs

Numerous times I have to take a string with values that are separated by spaces and replace them with tabs. Here's an example:

Jane       Doe     Start     Finish

It's usually a field list I dumped from SQL Server and I need to drop it in as cells in spreadsheet

here's the VBA script I used to do this:
In a Word VBA Module (usualy a module for tools in the 'Normal.dot' file)

Public Sub ReplaceSpacesWithTabs()
Dim slct As Selection 'current selection
Dim s As String 'string to manipulate
Dim i As Integer 'counter
'set selection to current selection
Set slct = ActiveDocument.ActiveWindow.Selection
'set string to manipulate
s = slct.Text
'loop through string replacing two spaces with one
'and do this as long as there are two spaces in the string
Do
i = Len(s)'measure string
s = Replace(s, " ", " ")
Loop While i <> Len(s)
'replace the single spaces with tabs 'chr(9)'
s = Replace(s, " ", Chr(9)) '9 = tab character
'reset the selection text with the tabbed text
slct.Text = s
End Sub



I copy and paste the field list and dump it in Word, select all, and then run the script (via a tool bar button.)