Skip to content
05/17/2022
  • FB
  • Twitter
  • YouTube
  • Instagram

An open mind, an open question…

Primary Menu
  • About
    • Editorial Clients
    • Election Calendar
    • Recommended Books
  • COVID Tracker
  • Japan YT Stars!
    • Audrey&Kate: Dynamic Duo!
    • BabySaster: Lolita Guitar Project
    • Naomi Club: Comedian, Actress, Fashion Designer!
    • Perfume: Electro-pop Trio
    • Yoyoka: Drummer Extraordinaire!
  • Know-It-All
    • Modern Art
    • Think on This
  • This is RUSH!
    • Rush Discography
    • RUSH Appreciation
    • RUSH Playlist
  • J-POP!
    • NOKKO – Hallelujah! (1992)
    • KEIZO NAKANISHI – Starting Over (1994)
  • Home
  • Code Snippets
  • Word VBA: Export TRADOS Segments to Text File
  • Code Snippets
  • Technology
  • VBA Macros

Word VBA: Export TRADOS Segments to Text File

admin 04/03/2022 200 words
Sub ExportSeg()
	'ExportSeg Macro - Created 2007/09/04 by Michael Grant
    'Created for ancient versions of TRADOS that ran as an MS Word plugin.
    'Could easily be extended to export as csv or xml/tmx.

    Selection.HomeKey unit:=wdStory  'Make sure we're at the beginning of the document
    
    Selection.Find.ClearFormatting  'Reset search parameters

    Open "C:\segments.txt" For Output As #1

    With Selection.Find
        .Text = "[{0>](*)[<}][0-9]{1,3}[{>](*)[<0}]{3}"  'Select the whole tag and start the "show"!
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchFuzzy = False
        .MatchWildcards = True

        Do While .Execute
            If Left$(Selection.Text, 3) = "{0>" Then  'Finds first matching translation unit

                step0 = Selection.Text
                step1 = Mid$(Selection.Text, 4)        'Trim off the opening TRADOS tag
                step2 = Left$(step1, (Len(step1) - 3)) 'Trim off the closing TRADOS tag
                                                       'step2 now equals: source_text<}0{>target_text
                step3 = InStr(step2, "<}")             'Find start pos of middle TRADOS tag
                step4 = InStr(step2, "{>")             'Find end pos of middle TRADOS tag

                strJPN = Left$(step2, (step3 - 1))                 'Save source text in a variable
                strENG = right$(step2, Len(step2) - (step4 + 1))   'Save target text in a variable
                If InStr(strJPN, ",") <> 0 Then
                    thisJPN = Chr(34) & strJPN & Chr(34)
                Else
                    thisJPN = strJPN
                End If
                If InStr(strENG, ",") <> 0 Then
                    thisENG = Chr(34) & strENG & Chr(34)
                Else
                    thisENG = strENG
                End If


                Print #1, thisENG & Chr(44) & thisJPN & Chr(44) & Selection.Information(wdActiveEndPageNumber)
            End If
        Loop
    End With

    Selection.Find.Execute

    Close #1
    Selection.Find.ClearFormatting  'Reset search parameters
    ' Display a message indicating the search has been completed.

    MsgBox (" DONE ")

End Sub
Print to PDF

Continue Reading

Previous: A High-Risk Medical Device Didn’t Meet Federal Standards. The Government Paid Millions for More.
Next: Is it possible to secure Apache Solr 8.5.1 dashboard page but not the query page?

Related Stories

How to Install and Configure Python on a Hosted Server
1,146 words
  • PDF
  • Technology
  • Web/Dev

How to Install and Configure Python on a Hosted Server

04/24/2022
Is it possible to secure Apache Solr 8.5.1 dashboard page but not the query page?
516 words
  • Code Snippets
  • Technology
  • Web/Dev

Is it possible to secure Apache Solr 8.5.1 dashboard page but not the query page?

04/21/2022
A High-Risk Medical Device Didn’t Meet Federal Standards. The Government Paid Millions for More.
954 words
  • Government
  • Health
  • Technology

A High-Risk Medical Device Didn’t Meet Federal Standards. The Government Paid Millions for More.

01/07/2022

You may have missed

How to Install and Configure Python on a Hosted Server
1,146 words
  • PDF
  • Technology
  • Web/Dev

How to Install and Configure Python on a Hosted Server

04/24/2022
Is it possible to secure Apache Solr 8.5.1 dashboard page but not the query page?
516 words
  • Code Snippets
  • Technology
  • Web/Dev

Is it possible to secure Apache Solr 8.5.1 dashboard page but not the query page?

04/21/2022
Word VBA: Export TRADOS Segments to Text File
200 words
  • Code Snippets
  • Technology
  • VBA Macros

Word VBA: Export TRADOS Segments to Text File

04/03/2022
No dinner at My Uncle’s with Tara Setmayer (The Mary Trump Show)
Length: 49:11
  • Feature Videos

No dinner at My Uncle’s with Tara Setmayer (The Mary Trump Show)

02/27/2022
  • Normal
  • Large
  • X-Large
  • FB
  • Twitter
  • YouTube
  • Instagram
Copyright © All rights reserved. | BGMusic by Spyro Gyra - Rites of Summer.