D:\Program Files\Microsoft Visual Studio\Common\MSDev98\Macros\MYMACRO2.DSM

Sub Application_BuildFinish(nNumErrors, nNumWarnings)
' written 7/11/00 by Curt Blackmon
' updated 10/10/01 by Valery A. Boronin
' updated 6/10/03 by keith pase
' e-mail any comments, corrections, etc. to shadowspawn@shadowspawn.net
' invoked automatically before build starts
' will open the project's *.h file as text
' will search for the version info
' and will increment the build number

    if (nNumErrors) > 0 then
        exit sub
    end if

    dim oDoc
    dim sBuild
    dim sRCFile
    dim sOne
    dim sTwo
    dim iSelect
    dim lLineNbr
    dim bFound
    dim bPass

    'get the name of the active project's whatever file
    sRCFile = "D:\cygwin\wf_fusion_src_r8\cvsroot\client\buildversion.h"

    'open file as text
    on error resume next 
    set oDoc = Documents.Open(sRCFile, "Text") 
    if not IsObject(oDoc) then 
        MsgBox "Cannot open " & sRCFile & " !" & vbLF & "It probably needs to be checked out. Do not forget the Resource.h file to.", vbOKOnly + vbInformation 
        exit sub 
    end if 
    on error goto 0 

    'position to the correct section of the file
    oDoc.Selection.FindText "#define BUILDVERSION ", dsMatchCase

    'save the line number for the next search
    lLineNbr = oDoc.Selection.CurrentLine

    'use a regular expression search string for the first version search
    sOne = "2."

    'find the first string
    oDoc.Selection.FindText sOne, dsMatchRegExp

    if oDoc.Selection.CurrentLine = lLineNbr then
        'convert the regular expression to an absolute search string
        sOne = oDoc.Selection
        'build an absolute search string for the strings with embedded spaces
        sTwo = Replace(sOne, "", " ")
        'move to the build number
        'select the build number
        oDoc.Selection.WordRight dsExtend
        'increment the build number
        sBuild = oDoc.Selection + 1
        'replace the old build number with the new one
        oDoc.Selection = sBuild
    else 'something went wrong
        msgbox "Version number 2 not found. Closing without changes."
        oDoc.Close dsSaveChangesNo
        set oDoc = nothing
        exit sub
    end if

    bPass=1 'sOne

    'close and save
    oDoc.Close dsSaveChangesYes
    set oDoc = nothing
End Sub