|
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 Ads Donate Humor |
Zero (strip) the parity bits of all bytes in a file - Word 2003 Visual Basic macroYet another routine to zero bit 8 (parity) of all characters in file so all characters have ASCII values < 128. For cleaning up log files of modem sessions or old WordStar files. Unfortunately, I found a note to myself saying this macro doesn't work in Word 2003. I put a note below at the error point. However, if you import a file into Word 2003 and select "encoded in US-ASCII" in the file conversion dialog box, it will do this conversion for you, so this macro is now obsolete. |
|
Attribute VB_Name = "MapdownParityBits"
Public Sub MAIN()
Attribute MAIN.VB_Description = "Zeroes bit 8 (parity) of all chars in file so all chars have ascii values < 128. For cleaning up log files of modem sessions.\r\n"
Attribute MAIN.VB_ProcData.VB_Invoke_Func = "TemplateProject.MapdownParityBits.MAIN"
Dim a
Rem Copyright (C)1999 Steven Whitney.
Rem Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
Rem ZEROES HIGH BIT (PARITY) OF ALL CHARS IN FILE
Rem SO ALL CHARS HAVE ASCII VALUES < 128.
Rem You should normally run this macro FIRST (before any control char
Rem handling) on a newly imported file.
Rem
Rem DUE TO SOME AUTOMATIC FORMATTING DURING EDITCLEAR(),
Rem THIS MACRO DOES *NOT* PRESERVE THE INTEGRITY OF THE ORIGINAL FILE,
Rem DOING *ONLY* THE PARITY STRIPPING.
Rem
Rem IF THAT IS WHAT YOU NEED, USE MY PROGRAM MAPDOWN.EXE.
Rem 11-26-99
Rem ----------------------------------------------------------------------------
If WordBasic.MsgBox("Run this macro only on a file freshly imported from text into MSWord. Also, a better choice is the program MAPDOWN.EXE. Continue anyway?", 36) <> -1 Then GoTo Bye
Rem ---------------------------------------------------------------------
Rem SECTION NOT NOW USED. MACRO NOW *DOES* CONVERT THESE CHARS.
Rem DON'T CONVERT CERTAIN CHARS USED BY MSWORD. SEE CLEANSTRING$() HELP.
Rem If a <> 160 And a <> 172 And a <> 176 And a <> 182 And a <> 183 Then
Rem EndIf
Rem ---------------------------------------------------------------------
WordBasic.StartOfDocument
While Not WordBasic.AtEndOfDocument()
Rem 1/19/06 ==> The next line does not work in Word 2003.
Rem Some brief testing failed to find an easy fix.
a = Asc(WordBasic.[Selection$]())
If a > 127 Then
Rem IT ONLY WORKS RIGHT IF YOU INSERT FIRST, THEN DELETE.
Rem OTHERWISE, SOME SPACES BETWEEN WORDS GET REMOVED ENTIRELY.
Rem 'AND' IS MUCH FASTER THAN A - 128
WordBasic.Insert Chr(a And 127) 'INSERT ORIGINAL AT LEFT
WordBasic.WW6_EditClear 'REMOVE ORIGINAL CHAR
Else
WordBasic.CharRight
End If
Wend
WordBasic.StartOfDocument
Rem ---------------------------------------------------------------------
Bye:
End Sub
|
|
|
|
|
|