Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Unicode to Symbol Macro
Hi everyone,
Firstly great little discussion section here. I've been reading alot of posts and it has been enlightening me a fair bit. I've been having issues with Symbols (who hasn't) and I've been scouring the net for solutions as well as having a go at creating a macro (which I eventually need to do anyway.) Here is my issue at hand... I have a document with multiple Unicode characters scattered throughout the document. The characters might be Arial or Times New Roman etc. The document looks something like this: --- Equation 1: 1 + 2 = 3 2 + 2 = 4 --- I need to convert ALL of the non-symbol characters (i.e. the unicode) to its Symbol equivalent. In this example it would be the plus and the equals sign. I've tried a few methods so far but none have worked for me. 1) Recording a Macro This had the most success for me except I could only perform a single find and replace as well as I couldn't format in Symbol. So the text would be replaced and show up as an incorrect character in Times New Roman etc. I.e. With Selection.Find .Text = ChrW(215) .Replacement.Font.Name = "Symbol" .Replacement.Text = ChrW(180) *Note I realise about the character numbers being incorrect now too. 2) Using the MVPS (http://word.mvps.org/FAQs/MacrosVBA/...aceSymbols.htm) This site helped me in greater understanding except I need an automated macro. The solution in the macro9.dot file means that each time I have to manually specify characters. 3) Klaus Linke's Solution I thought I'd hit a home run when I found this one. Essentially this is what I wanted to do. I was however just going to manually specify the ones I needed to do. (i.e. "+" "-" and any others) His solution was: Sub UnicodeToSymbolFont() ' Replaces Unicode symbols with symbols from the Symbol font ' in all of the doc (all story ranges). Call U2S(&H2200, &H22) ' # FOR ALL Call U2S(&H2203, &H24) ' # THERE EXISTS Call U2S(&H220B, &H27) ' # CONTAINS AS MEMBER Call U2S(&H2217, &H2A) ' # ASTERISK OPERATOR .... (continues) However this was really slow (I think something to do with the loop) as well as my test document which had: +-×÷ It only worked on the X. So I was stumped there too. If anyone knows of a solution at the moment I have almost lost hope! Thanks, David. |
#2
|
|||
|
|||
Hi Dave,
Why do you want to use the Symbol font for characters that are available from any regular font? That would be against my religion ;-) ... Anyway: For the four arithmetic operators +-×÷, you'd need the following lines in the UnicodeToSymbolFont macro. Deleting the other 163 lines should speed up the macro a bit. Call U2S(&HD7, &HB4) ' # MULTIPLICATION SIGN Call U2S(&H2B, &H2B) ' # PLUS SIGN Call U2S(&H2D, &H2D) ' # MINUS SIGN Call U2S(&HF7, &HB8) ' # DIVISION SIGN Since the multiplication and division signs in the Symbol font have different codes from the same characters in regular fonts, the characters will be messed up when you change to any other font later on. To avoid that, you'd need to run the macro ProtectSymbols... But that's rather slow, too :-( Regards, Klaus "daveid_m" schrieb im Newsbeitrag ... Hi everyone, Firstly great little discussion section here. I've been reading alot of posts and it has been enlightening me a fair bit. I've been having issues with Symbols (who hasn't) and I've been scouring the net for solutions as well as having a go at creating a macro (which I eventually need to do anyway.) Here is my issue at hand... I have a document with multiple Unicode characters scattered throughout the document. The characters might be Arial or Times New Roman etc. The document looks something like this: --- Equation 1: 1 + 2 = 3 2 + 2 = 4 --- I need to convert ALL of the non-symbol characters (i.e. the unicode) to its Symbol equivalent. In this example it would be the plus and the equals sign. I've tried a few methods so far but none have worked for me. 1) Recording a Macro This had the most success for me except I could only perform a single find and replace as well as I couldn't format in Symbol. So the text would be replaced and show up as an incorrect character in Times New Roman etc. I.e. With Selection.Find .Text = ChrW(215) .Replacement.Font.Name = "Symbol" .Replacement.Text = ChrW(180) *Note I realise about the character numbers being incorrect now too. 2) Using the MVPS (http://word.mvps.org/FAQs/MacrosVBA/...aceSymbols.htm) This site helped me in greater understanding except I need an automated macro. The solution in the macro9.dot file means that each time I have to manually specify characters. 3) Klaus Linke's Solution I thought I'd hit a home run when I found this one. Essentially this is what I wanted to do. I was however just going to manually specify the ones I needed to do. (i.e. "+" "-" and any others) His solution was: Sub UnicodeToSymbolFont() ' Replaces Unicode symbols with symbols from the Symbol font ' in all of the doc (all story ranges). Call U2S(&H2200, &H22) ' # FOR ALL Call U2S(&H2203, &H24) ' # THERE EXISTS Call U2S(&H220B, &H27) ' # CONTAINS AS MEMBER Call U2S(&H2217, &H2A) ' # ASTERISK OPERATOR ... (continues) However this was really slow (I think something to do with the loop) as well as my test document which had: +-×÷ It only worked on the X. So I was stumped there too. If anyone knows of a solution at the moment I have almost lost hope! Thanks, David. |
#3
|
|||
|
|||
Hi Klaus,
Thanks for the reply! Sorry for my late reply work is terrible Why do you want to use the Symbol font for characters that are available from any regular font? I am trying to run a script on the documents that can only handle the symbol characters. Secondly, IT WORKS! Thanks heaps Klaus I will now create small quick macros to run using the scheme as a guide. Your help has been invaluable to me! Klaus the man! Thanks, David M. "Klaus Linke" wrote: Hi Dave, Why do you want to use the Symbol font for characters that are available from any regular font? That would be against my religion ;-) ... Anyway: For the four arithmetic operators +-×÷, you'd need the following lines in the UnicodeToSymbolFont macro. Deleting the other 163 lines should speed up the macro a bit. Call U2S(&HD7, &HB4) ' # MULTIPLICATION SIGN Call U2S(&H2B, &H2B) ' # PLUS SIGN Call U2S(&H2D, &H2D) ' # MINUS SIGN Call U2S(&HF7, &HB8) ' # DIVISION SIGN Since the multiplication and division signs in the Symbol font have different codes from the same characters in regular fonts, the characters will be messed up when you change to any other font later on. To avoid that, you'd need to run the macro ProtectSymbols... But that's rather slow, too :-( Regards, Klaus "daveid_m" schrieb im Newsbeitrag ... Hi everyone, Firstly great little discussion section here. I've been reading alot of posts and it has been enlightening me a fair bit. I've been having issues with Symbols (who hasn't) and I've been scouring the net for solutions as well as having a go at creating a macro (which I eventually need to do anyway.) Here is my issue at hand... I have a document with multiple Unicode characters scattered throughout the document. The characters might be Arial or Times New Roman etc. The document looks something like this: --- Equation 1: 1 + 2 = 3 2 + 2 = 4 --- I need to convert ALL of the non-symbol characters (i.e. the unicode) to its Symbol equivalent. In this example it would be the plus and the equals sign. I've tried a few methods so far but none have worked for me. 1) Recording a Macro This had the most success for me except I could only perform a single find and replace as well as I couldn't format in Symbol. So the text would be replaced and show up as an incorrect character in Times New Roman etc. I.e. With Selection.Find .Text = ChrW(215) .Replacement.Font.Name = "Symbol" .Replacement.Text = ChrW(180) *Note I realise about the character numbers being incorrect now too. 2) Using the MVPS (http://word.mvps.org/FAQs/MacrosVBA/...aceSymbols.htm) This site helped me in greater understanding except I need an automated macro. The solution in the macro9.dot file means that each time I have to manually specify characters. 3) Klaus Linke's Solution I thought I'd hit a home run when I found this one. Essentially this is what I wanted to do. I was however just going to manually specify the ones I needed to do. (i.e. "+" "-" and any others) His solution was: Sub UnicodeToSymbolFont() ' Replaces Unicode symbols with symbols from the Symbol font ' in all of the doc (all story ranges). Call U2S(&H2200, &H22) ' # FOR ALL Call U2S(&H2203, &H24) ' # THERE EXISTS Call U2S(&H220B, &H27) ' # CONTAINS AS MEMBER Call U2S(&H2217, &H2A) ' # ASTERISK OPERATOR ... (continues) However this was really slow (I think something to do with the loop) as well as my test document which had: +-×÷ It only worked on the X. So I was stumped there too. If anyone knows of a solution at the moment I have almost lost hope! Thanks, David. |
#4
|
|||
|
|||
Thanks for the reply! Sorry for my late reply work is terrible
I can relate :-/ [...] IT WORKS! That is what's important ;-) Enjoy the weekend (while it lasts) Klaus |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Convert to Symbols | Microsoft Word Help | |||
Macro Button Won't Stay on Toolbar | Microsoft Word Help | |||
Possible bug when recording a Word Macro | Microsoft Word Help | |||
Insert Symbols: All of Them | Microsoft Word Help | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |