Добавлено: 17 дек 2004, 15:39
ну новички, мы новички, что поделаешь, нужно же кого-то помучать своими проблемами
Код: Выделить всё
REM ***** Recode from cp1252 to cp1251 for Word and Excel files without language set.
REM ***** Authors Dmitry G. Mastrukov and A. Novodroskii 2002, code corrercted by Dmitri Gabinski
REM ***** GPL license
Dim mCP1252(123) As String
Dim mCP1251(123) As String
Sub Init
mCP1252() = Array("?","‚","¸","„","…","†","‡","ˆ","‰","Š","‹","Œ","Ž", _
"‘","’","“","”","•","–","—","™","š","›","œ","¡","ž", _
"Ÿ"," ","¡","¢","£","¤","¥","¦","§","¨","©","ª","«", _
"¬","","®","¯","°","±","²","³","´","µ","¶","·","¸", _
"¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å", _
"Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò", _
"Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß", _
"à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì", _
"í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù", _
"ú","û","ü","ý","þ","ÿ")
mCP1251() = Array("Ђ","‚","ё","„","…","†","‡","?","‰","Љ","‹","Њ","Ћ", _
"‘","’","“","”","•","–","—","™","љ","›","њ","ќ","ћ", _
"џ"," ","Ў","ў","Ј","¤","Ґ","¦","§","Ё","©","Є","«", _
"¬","","®","Ї","°","±","І","і","ґ","µ","¶","·","ё", _
"№","є","»","ј","Ѕ","ѕ","ї","А","Б","В","Г","Д","Е", _
"Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т", _
"У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я", _
"а","б","в","г","д","е","ж","з","и","й","к","л","м", _
"н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ", _
"ъ","ы","ь","э","ю","я")
End Sub
Sub RecodeAllWriter
Dim n As Long
Dim oDocument As Object
Dim oReplace As Object
Init()
oDocument = ThisComponent
oReplace = oDocument.createReplaceDescriptor
For n = lbound(mCP1252()) To ubound(mCP1252())
oReplace.SearchString = mCP1252(n)
oReplace.ReplaceString = mCP1251(n)
oReplace.SearchCaseSensitive = TRUE
oDocument.replaceAll(oReplace)
Next n
MsgBox "Преобразовано"
End Sub
Sub RecodeAllCalc
Dim n As Long
Dim m As Long
Dim oDocument As Object
Dim oReplace As Object
Init()
On error goto ex
oDocument = ThisComponent
m = 0
While 1 = 1
oReplace = oDocument.Sheets(m).createReplaceDescriptor
For n = lbound(mCP1252()) To ubound(mCP1252())
oReplace.SearchString = mCP1252(n)
oReplace.ReplaceString = mCP1251(n)
oReplace.SearchCaseSensitive = TRUE
oDocument.Sheets(m).replaceAll(oReplace)
Next n
m = m + 1
Wend
ex:
MsgBox "Преобразовано"
End Sub