Chris; Rae 's VBA Pages

Routines Archive Index Last updated 21 Mar 2008

This page is made up from one big Word document by a macro which could at best be called "bespoke". Click the routine names to see their source code. A special thank-you must go to Al Ashcroft for his invaluable professional input on the Really() functions.

GetUserName (module) Get the user's network login name. Works with both Novell and Microsoft networking under NT 3.51, NT4, Win95, Win98 and Win2000. Thanks to Wade Jackson at Microsoft for some useful info.
ShellExecute (module) Run a given program or load the program associated with a document type (i.e. ShellEx "test.txt" would open the file in notepad).
DeleteTextInDebugWindow1 One way to clear all the text in the Immediate window. I really can't take the credit because Cindy Meister wrote it. If you have difficulty getting it to work (SendKeys is always awkward) then try DeleteTextInDebugWindow2().
DeleteTextInDebugWindow2 The other way to clear all the text in the Immediate window. Cindy Meister wrote this one too.
DeleteTextInDebugWindow3 Wish I'd never started this. Romke Soldaat wrote this one!
RevInStr (returns Integer) findin As String, tofind As String Find a character in a string, only backwards
BubbleSort ToSort As Variant, Optional SortAscending As Boolean = True Sort the given array into order. The sort used is "bubble sort" and defaults to ascending.
PrintMyself Utterly useless - my suggestion for the "smallest VBA program that can print itself" fight.
ShowAllFonts Display all the fonts available for use.
FillUpMenuSpace I'd like comments on this one - I think it shows a bug in Word (both '97 and 2000).
CommaDelimited (returns String) inarr As Variant, Optional delim As String = "," Return an array as a comma-delimited string. Should work with most types.
SendMail Send a mail item using Outlook. Will work from all incarnations of VBA.
DirExists (returns Boolean) ByVal strDirName As String Check whether the specified path exists.
ReallyChDir (returns Boolean) IntoDir As String Really change directory (and drive)
Ordinal (returns String) ByRef lngCardinal As Long This really isn't mine at all; I put a one-liner on my web site and Will sent me one that actually worked.
GetTempPath (module) Find the temporary file path used by Windows.
AddressWholeDocumentText (module) Run a search and replace on the whole text of the document including sectioned headers and footers. The routine can easily be altered to perform a different operation.
QuitWhenPrinted (module) Quit as soon as Word has finished printing. Note that if a problem occurs during the print requiring user intervention, the routine will wait until this is complete. Not much I can do about that, I'm afraid.
RegExpStuff (module) Regular Expression parser
SelfModify (module) Self-modifying VBA code
Queue (module) Queue class. Can do FIFO or LIFO, any sort of objects/vars.
NumsToText (module) Convert numbers to text. Might not work with fractions, now I look at it. Hrrhum.

You're free to use these routines for anything you want - all I ask is that for commercial use you give me credit somewhere. You may instead want to head back to the index for my Visual Basic for Applications Pages. Please do NOT mail me asking for help with programs - I am not MS tech support; I don't have time to reply and deleting the messages makes me feel guilty.