#1
|
|||
|
|||
Macro help - converting proprietary encoding to unicode, keep formatting
Hello,
I work for a publishers, and we've received a word document using a font with proprietary encoding for Egyptian transliteration. For our xml capture and online distribution, we wish to convert this to unicode. As this is at the early manuscript submission stage, we wish to keep the Word document formatting. It should be a find and replace procedure. Any advice appreciated, I am quite clueless of VBA macros but very willing to learn.
I hope this all makes sense. Thanks in advance. |
#2
|
||||
|
||||
Try running the following macro from the document you want to convert.
Code:
Sub EgyptReformatter() Application.ScreenUpdating = False Dim FRDoc As Document, FRList, j As Long Set FRDoc = Documents.Open("C:\Users\" & Environ("UserName") & "\Documents\Egypt List.txt", _ ReadOnly:=True, Addtorecentfiles:=False, Visible:=False) FRList = FRDoc.Range.Text FRDoc.Close False: Set FRDoc = Nothing With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .MatchWholeWord = True .MatchCase = True For j = 0 To UBound(Split(FRList, vbCr)) - 1 If InStr(FRList, vbTab & vbTab) > 0 Then If Split(Split(FRList, vbCr)(j), vbTab)(6) > 0 Then .Text = Split(Split(FRList, vbCr)(j), vbTab)(0) .Replacement.Text = Split(Split(FRList, vbCr)(j), vbTab)(3) .Execute Replace:=wdReplaceAll DoEvents End If End If Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks – I couldn't get your macro to work, but I tried looking at this again. If I can do it like this, I'm there. It's just a case of figuring out how to make this work with unicode on the line StrNew = "α,β,γ"
HTML Code:
' ConvertTable Macro Sub ConvertTable() Dim StrOld As String, StrNew As String Dim RngFind As Range, RngTxt As Range, i As Long StrOld = "a,b,c" StrNew = "α,β,γ" Set RngTxt = Selection.Range For i = 0 To UBound(Split(StrOld, ",")) Set RngFind = RngTxt.Duplicate With RngFind.Find ' Clear all previously set formatting for Find dialog box. .ClearFormatting ' Set font to Find for replacement. .Font.Name = "bwgrkl" ' Clear all previously set formatting for Replace dialog box. .Replacement.ClearFormatting ' Set font to Replace found font. .Replacement.Font.Name = "Arial Unicode MS" ' Don't find or replace any text. .Text = Split(StrOld, ",")(i) .Replacement.Text = Split(StrNew, ",")(i) .Format = True .MatchCase = True .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With Next End Sub |
#4
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fixing/stabilizing/setting/securing/converting markup of tracked changes into "hard" formatting | paulkaye | Word | 6 | 08-20-2015 02:36 AM |
Custom Dictionary & Unicode encoding? | markus staubmann | Word | 3 | 03-28-2012 05:23 AM |
Outlook macro for automatically converting plain text to link? | nrogers64 | Outlook | 1 | 09-17-2010 01:35 AM |
Unicode Encoding Type | Rose44 | Excel | 2 | 08-09-2009 09:05 PM |
Having some formatting issues after converting PDF to .doc | amf25 | Word | 1 | 06-05-2009 02:05 PM |