VBA Coding Examples

 

The VBA coding examples are included the macros file named "Samples.macro."

 

Sample type: VBA code

Sample name: "Samples.macro"

Directory (location): ...\Samples\Developing\Programming\VBA\

 

 

Enabling the Macros File

The macros file must be added to (i.e., enabled for use in) RC-WinTrans.  You can do this in one of two ways:

a.

use the drag-and-drop mechanism to move the file to the main window of RC-WinTrans; or

b.

select the Macros Files command from the Tools menu.

 

NOTE: RC-WinTrans will ask you to copy the macros file to the default folder for macros files in the RC-WinTrans installation directory.  Close the message box with "No" to not make a copy of the macros file and use the file in the sample directory.

 

The sample program can be run once the macros file is added to RC-WinTrans.

 

 

Loop for Translation Units

This is a loop for accessing the translation units (TUs) of all the project files in a translation project.  The source and target text is sent to RC-WinTrans' Output window if the translation unit's resource type is a text type.

 

NOTES:

1.

Other translation units may carry data such as size, location, or binary image data.  The sample filters shown here are for TUs with text.

2.

TUs can be filtered by text type using the "RestypeIsTranslatable" function implemented in RC-WinTrans X8's system macros.

 

Sub AllTUs()

  Dim Project As TranslationProject

  Dim TU As TransUnit

  Dim ProjFile As ProjectFile

  Dim bIsTextType As Boolean

  Dim SourceText As String

  Dim TargetText As String

 

  Set Project = RCWinTrans.ActiveProject  ' the active translation project

  If Project Is Nothing Then

    Exit Sub

  End If

 

  For Each ProjFile In Project.ProjectFiles

    For Each TU In ProjFile.TransUnits

 

      bIsTextType = SystemMacros.RestypeIsTranslatable(TU.Restype)

      If bIsTextType = True Then

      

         SourceText = TU.Source  ' the source text

         TargetText = TU.Target  ' the translation

 

         ' Output

         RCWinTrans.Windows.MultiViewBar.Output.AddText (SourceText & " -- " & TargetText)

 

      End If

 

     Next TU

  Next ProjFile

 

End Sub

 

 

 

Loop for Files

This is a loop for accessing the (source) files of a translation project.

 

Sub AllProjFiles()

  Dim Project As TranslationProject

  Dim ProjFile As ProjectFile

 

 Set Project = RCWinTrans.ActiveProject  ' the active translation project

  If Project Is Nothing Then

    Exit Sub

  End If

 

  For Each ProjFile In Project.ProjectFiles

 

 '   here: access to the project file object "ProjFile"

 

  Next ProjFile

 

End Sub

 

^ Top ^