I work in an organisation with 47 member states and two official languages, English and French. I would like to be able to produce a simple macro that would run through a Corel Draw graphic (e.g. a pie-chart) and change the names of all the countries from English to French.
I tried recording a macro, but the result was a series of messages in the macro telling me that “Recording of this command is not supported: TextEdit”.
Does anyone know if it’s possible to do what I want?
David Crowe said:but it doesn’t modify anything either
Hmmmm, I tried your code, it worked for me. It wouldn't work if there are any other characters in the text (space, punctuation, multiple words, etc.) This is because the if statement checks the whole text. It also wouldn't work if the character case was different (i.e. lowercase, uppercase).
The following will search for text within. Note that it is still case sensitive (e.g. if you country is "andorra", it won't work, it needs to be "Andorra")
' find toFind in str and replace with toReplacePublic Function FindReplace(ByVal str As String, ByVal toFind As String, ByVal toReplace As String) As String Dim i As Integer For i = 1 To Len(str) If Mid(str, i, Len(toFind)) = toFind Then ' does the string match? FindReplace = FindReplace & toReplace ' add the new replacement to the final result i = i + (Len(toFind) - 1) ' move to the character after the toFind Else FindReplace = FindReplace & Mid(str, i, 1) ' add a character End If Next iEnd Function
Public Sub TextTranslate() Dim s As Shape ActiveDocument.BeginCommandGroup "Text Translate" For Each s In ActiveDocument.ActivePage.Shapes If s.Type = cdrTextShape Then s.Text.Story = FindReplace(s.Text.Story, "Andorra", "Andorre") s.Text.Story = FindReplace(s.Text.Story, "Albania", "Albanie") End If Next s ActiveDocument.EndCommandGroupEnd Sub
That works! Great.
I shall fill it out with the other 45 countries and try it on some real documents.
Well, that’s exactly what I wanted. Many thanks for your help.
It will save me considerable time already, and now I know the technique I can develop it for other situations.
hi Ariel,
This is good info from you.. thanks for taking this time.
Curious, can you suggest better engine? It should be possible for us to hook into anything online, perhaps not through back-end API, but through usual web interface.
As you say, the conversion quality depends on how well the original English is written...
LOL... maybe you have seen instruction manuals that have come from the Orient after conversions to English? I got one with a digital scale this last Christmas. Usually you can "make out" what they are trying to communicate, but this one was so far out to lunch there was no hope.
Maybe you are like me... for a short thing, I almost want to translate to English for FREE, to help. In an online dating forum, I saw a Latin gal who seemed quite nice. Her profile was understandable, but I took 10 minutes to correct it to perfect English.
She was quite offended! Then I explained.. if I was on dating site in Russia (as an example) and someone offered to improve my poor Russian profile, why would I say no? Oh well.
Ariel said:The Macro Translator is a powerful addition, but it need to use a better engine than Google
>>She was quite offended! Then I explained.. if I was on dating site in Russia (as an example)>>and someone offered to improve my poor Russian profile, why would I say no? Oh well.
The problem is, lots of people think they can speak and write English. And in a way, they can. Whereas in your Russian example, we are happy to accept that “control” of the language is in the hands of speakers of Russian as a first language.
Despite efforts some three hundred years ago to found an English “academy” to protect the language, there has never been a single authority on what constitutes good and less good English. Since for decades we have recognised different forms of English (British, US, Canadian, Australian), there is little to prevent the development of other forms, such as Euro-English, Chinese English, South American English.
A Dutch colleague asked me years ago to correct a letter for him. I made minor changes, and returned it with the comment that modalities wasn’t really a word in English – at least not in the sense he was using it. He said he knew, but the recipients of the letter were all used to the term, they even expected to see it in such a letter. In the context it’s hard to refute the argument that modalities is the right word for his readership.
Sorry, getting a bit OT.