Translating OptionButtons in a Word file

I have a .docx file which includes a questionnaire. The answers are chosen via radio buttons (see image below), but I can't get Trados to extract the text for these options.

Screenshot showing a .docx file with a questionnaire and radio buttons for ethnic origin options such as Asian, Asian - Bangladeshi, Asian - Chinese, Asian - Indian, and Asian - Pakistani.

I've tried selecting as many things as I can under 'embedded content' when preparing the files (Radio button, check box and man y others...), as well as every reasonable and unreasonable option under 'common', but it doesn't want to extract this text. In Word itself, to edit I have to use the Developer tab, click Design Mode, then right click on each answer, go to object, then 'Edit', not sure if this process is what's blocking Studio from extracting?

This is the properties info for one of the buttons:

Screenshot of the properties window for a radio button in a Word document, showing settings like Name, Caption, Font, ForeColor, and other properties.

I'm on Trados Studio 2021 SR2 Freelance edition.



Generated Image Alt-Text
[edited by: Trados AI at 11:39 AM (GMT 1) on 17 Apr 2024]
emoji
  •  

    I don't know if it possible, but I’d try with these check boxes in your Project Settings:

    Trados Studio Project Settings window showing 'Common' options under 'File Types' with two checkboxes 'Process locked content controls' and 'List item values' highlighted in red.

    Tick them both and use the Preview button at the bottom to quickly confirm that the radio buttons content is extracted.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 12:43 PM (GMT 1) on 17 Apr 2024]
  • Thanks for the reply - I've already tried those and no joy. I think there may be some macros involved because after starting on manually amending them in Word (urgh), I'm asked to save as a macro-enabled document. Very annoying as it's a bog standard questionnaire that should take me next to no time...

    emoji
  •  

    Sorry it was not working.

    Please reject my answer above, so other peers see this post is still not answered.

    emoji
  • Oh my Gosh  

    I have spent a fair bit of time looking at all options.
    XML, Exporting of Macro Properties which gave a *.cls file that did not contain my radio button caption <-GRR


    Seems nothing I do within MS Word will give me direct access to those radio button labels/content/caption 

    Not sure if  is aware of a scripting tool that will capture the caption info for export. So you treat it as a second project only to then import it back / update the original for a complete delivery.

    Lyds

    Lydia Simplicio | RWS Group

    _______
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji
  •   

    I guess you could use a macro to extract the values into Excel.  Translate the Excel and then  import back into Word with another macro.  In principle it can work ;-)  For example. I have this Word file:

    Screenshot of a Word document showing a list of option buttons for ethnic origin with options such as Asian, Asian - Bangladeshi, Asian - Chinese, Asian - Indian, and Asian - Pakistani.

    I use this macro:

    Sub ExportActiveXControlsToExcel()
        Dim xlApp As Object
        Dim xlBook As Object
        Dim xlSheet As Object
        Dim ctrl As Object
        Dim i As Integer
    
        ' Create a new Excel instance
        Set xlApp = CreateObject("Excel.Application")
        xlApp.Visible = True
        Set xlBook = xlApp.Workbooks.Add
        Set xlSheet = xlBook.Worksheets(1)
    
        i = 1
        ' Loop through all ActiveX controls in the Word document
        For Each ctrl In ActiveDocument.InlineShapes
            If TypeName(ctrl.OLEFormat.Object) = "OptionButton" Then
                xlSheet.Cells(i, 1).Value = ctrl.OLEFormat.Object.Name
                xlSheet.Cells(i, 2).Value = ctrl.OLEFormat.Object.Caption
                i = i + 1
            End If
        Next ctrl
    
        ' AutoFit columns for better visibility
        xlSheet.Columns("A:B").AutoFit
    End Sub

    That gets me an Excel like this:

    Screenshot of an Excel spreadsheet with two columns, A and B, listing OptionButton names and their corresponding captions for ethnic origins such as Asian, Asian - Bangladeshi, Asian - Chinese, Asian - Indian, and Asian - Pakistani.

    I translate that like this:

    Screenshot of an Excel spreadsheet with two columns, A and B, showing translated captions for ethnic origins with options such as English, English - Bangladeshi, English - Chinese, English - Indian, and English - Pakistani.

    Then run this macro from the original Word file:

    Sub ImportTranslatedCaptionsFromExcel()
        Dim xlApp As Object
        Dim xlBook As Object
        Dim xlSheet As Object
        Dim ctrl As Object
        Dim i As Integer
        Dim fd As Object
        Dim wsPath As String
    
        ' Create a FileDialog object as Open File dialog
        Set fd = Application.FileDialog(1) ' 1 = msoFileDialogOpen
        With fd
            .Title = "Select the Excel file with translations"
            .Filters.Clear
            .Filters.Add "Excel Files", "*.xls; *.xlsx; *.xlsm"
            If .Show = -1 Then ' -1 means the user pressed OK
                wsPath = .SelectedItems(1) ' Get the path of selected file
            Else
                ' Exit the Sub if no file is selected
                MsgBox "No file selected. Exiting...", vbExclamation
                Exit Sub
            End If
        End With
    
        ' Create a new Excel instance and open the workbook
        Set xlApp = CreateObject("Excel.Application")
        xlApp.Visible = True
        Set xlBook = xlApp.Workbooks.Open(wsPath)
        Set xlSheet = xlBook.Worksheets(1)
    
        ' Loop through all InlineShapes in the Word document
        For Each ctrl In ActiveDocument.InlineShapes
            If TypeName(ctrl.OLEFormat.Object) = "OptionButton" Then
                For i = 1 To xlSheet.Cells(xlSheet.Rows.Count, 1).End(-4162).Row  ' -4162 corresponds to xlUp
                    ' Match the control based on the name stored in Excel column A
                    If ctrl.OLEFormat.Object.Name = xlSheet.Cells(i, 1).Value Then
                        ' Update the Caption of the control with the translated text from Excel column B
                        ctrl.OLEFormat.Object.Caption = xlSheet.Cells(i, 2).Value
                        Exit For
                    End If
                Next i
            End If
        Next ctrl
    
        ' Clean up
        xlBook.Close SaveChanges:=False
        xlApp.Quit
        Set xlSheet = Nothing
        Set xlBook = Nothing
        Set xlApp = Nothing
        Set fd = Nothing
    End Sub

    Now I have a Word file like this:

    Screenshot of a Word document showing a list of option buttons for ethnic origin with updated captions translated to English, including English, English - Bangladeshi, English - Chinese, English - Indian, and English - Pakistani.

    It's tricky as I think these are all ActiveX controls and I don't think Studio can read the captions.  You'll almost certainly need to test thoroughly as I have no idea what else is in your file... mine is a simple example to test the theory.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 1:41 AM (GMT 1) on 1 May 2024]