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 6.0 macro to remove backspace characters embedded in a file

Old disk files containing text from modem capture buffer routines (which saved the characters typed as they were sent to the modem) often contain embedded backspace characters intermingled with the characters they backspaced over.

For example, if you typed "this", then 2 backspaces, then changed it to "these", the text in the file would look like this: this^H^Hese.

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

There is a version of this macro for Microsoft Word 2003 Visual Basic

StripBackspaceChars - remove backspaces embedded in a file

Removes backspace chars and the chars they backspaced over.  For cleaning up log files of modem sessions.

Sub 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.
StartOfDocument
EditFindClearFormatting
EditFind .Find = "^0008", .Direction = 0, .MatchCase = 0, .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format = 0, .Wrap = 0
While EditFindFound()
	EditClear			REM delete the backspace
	CharLeft 1, 1		REM select the char to the left
	EditClear			REM and delete it, too
	RepeatFind
Wend
End Sub

 

Valid HTML 4.01 Transitional
Yahoo! Search
Search the web Search this site
Valid CSS