+ Reply to Thread
Results 1 to 2 of 2

Translation routine

Hybrid View

  1. #1
    Registered User
    Join Date
    01-01-2010
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    34

    Translation routine

    Hi,

    I'd like to translate an export from a Dutch program into English. Luckily most text are just words instead of sentences. First I recorded my steps with 'find and replace' then I copied the code for all other words to be translated. Unfortunately after tens of words the code becomes messy. I've read the variable Collection would do the trick.

    I tried to write this:

    Dim Coll As New Collection
    
    Coll.Add "Report", "Rapport"
    Coll.Add "Version", "Versie"
    'Coll.Add many many other words
    
    For i = 1 To Coll.Count
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = Coll(i)
            .Replacement.Text = Coll(.Key)
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = True
            .MatchWholeWord = True
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    Next i
    I think the problem lies within .Key but can't figure out what I'm doing wrong here. If I write
     MsgBox Coll("Versie")
    the popup translates it into English and shows "Version". Why isn't this working in the replacement text?

    Thank you in advance,
    Erik

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Translation routine

    A Collection doesn't have a Key property.

    Look instead at the Dictionary object, which stores Key/Item pairs. Even the name sounds appropriate to the application ...
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1