25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Payments   Humor   Music

Microsoft Word 2003 Visual Basic macro to remove backspace characters embedded in a file

Old disk files containing text from modem capture buffer routines often contain embedded backspace characters intermingled with the characters they backspaced over.

Example: this^H^Hese.

This macro removes the backspace characters and the characters they backspaced over, leaving only the final-form text.

StripBackspaceChars

Attribute VB_Name = "StripBackspaceChars"

Public Sub MAIN()
Attribute MAIN.VB_Description = "Removes backspace chars and the chars they backspaced over.  For cleaning up log files of modem sessions.\r\n"
Attribute MAIN.VB_ProcData.VB_Invoke_Func = "TemplateProject.StripBackspaceChars.MAIN"
Rem 11-24-99
Rem Copyright (C)1999 Steven Whitney.
Rem Initially published by http://25yearsofprogramming.com.
Rem Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
Rem REMOVES FROM A FILE ALL BACKSPACE CHARS AND THE CHARS THEY BACKSPACED OVER.
Rem FOR CLEANING UP LOG FILES OF MODEM SESSIONS.

WordBasic.StartOfDocument
WordBasic.EditFindClearFormatting
WordBasic.EditFind Find:="^0008", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, Format:=0, Wrap:=0
While WordBasic.EditFindFound()
    WordBasic.WW6_EditClear         ' delete the backspace
    WordBasic.CharLeft 1, 1     ' select the char to the left
    WordBasic.WW6_EditClear         ' and delete it, too
    WordBasic.RepeatFind
Wend
End Sub

 

 

Valid HTML 4.01 Transitional Valid CSS
Yahoo! Search
Search the web Search this site
View content labeling at ICRA.