Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2016, 04:04 AM
kmawhood kmawhood is offline Macro help - converting proprietary encoding to unicode, keep formatting Windows 10 Macro help - converting proprietary encoding to unicode, keep formatting Office 2010 64bit
Novice
Macro help - converting proprietary encoding to unicode, keep formatting
 
Join Date: Apr 2016
Posts: 2
kmawhood is on a distinguished road
Default 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.
  • Attached: Details of the "Source value" to "Unicode value", identified from the glyphs in the font.
  • Font copyright: Glyph for Windows' Egyptian transliteration font v. 2.1; provided by the Centre for Computer-aided Egyptological Research, Utrecht University, The Netherlands.

I hope this all makes sense. Thanks in advance.
Attached Files
File Type: txt Egypt_List.txt (2.7 KB, 17 views)
Reply With Quote
  #2  
Old 04-16-2016, 03:09 AM
macropod's Avatar
macropod macropod is offline Macro help - converting proprietary encoding to unicode, keep formatting Windows 7 64bit Macro help - converting proprietary encoding to unicode, keep formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
As coded, the macro expects to find the 'Egypt List.txt' file in the user's 'Documents' folder.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-29-2016, 07:03 AM
kmawhood kmawhood is offline Macro help - converting proprietary encoding to unicode, keep formatting Windows 10 Macro help - converting proprietary encoding to unicode, keep formatting Office 2010 64bit
Novice
Macro help - converting proprietary encoding to unicode, keep formatting
 
Join Date: Apr 2016
Posts: 2
kmawhood is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 04-29-2016, 04:06 PM
macropod's Avatar
macropod macropod is offline Macro help - converting proprietary encoding to unicode, keep formatting Windows 7 64bit Macro help - converting proprietary encoding to unicode, keep formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
I couldn't get your macro to work
Well, if you said what the problem was, some progress might be made.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro help - converting proprietary encoding to unicode, keep formatting Fixing/stabilizing/setting/securing/converting markup of tracked changes into "hard" formatting paulkaye Word 6 08-20-2015 02:36 AM
Macro help - converting proprietary encoding to unicode, keep formatting Custom Dictionary & Unicode encoding? markus staubmann Word 3 03-28-2012 05:23 AM
Macro help - converting proprietary encoding to unicode, keep formatting Outlook macro for automatically converting plain text to link? nrogers64 Outlook 1 09-17-2010 01:35 AM
Macro help - converting proprietary encoding to unicode, keep formatting 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft