Handling Translation when Customizing with VBA

David Meego - Click for blog homepageThis is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.

From the Translating Dexterity Applications Series.

The final topic in the series is one that was added later after I was asked about how to handle translated applications when writing customizations.

Most code would work fine as it is independent of the language. However, it is common in Visual Basic for Applications (VBA) customizations to read the prompt from a dialog using the Window_AfterModalDialog() event and take action based on the prompt text.  On a translated system this text will differ.

The solution is that you would need to look for the prompt in each language.  You can use a select case statement as shown in the US English versus International English example below:

VBA Code Example

Private Sub Window_AfterModalDialog(ByVal DlgType As DialogType, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As DialogCtrl)
  Select Case PromptString
    Case "Are you sure you want to delete this Customer ID?"

    Case "Are you sure you want to delete this Debtor ID?"

    Case Else
  End Select
End Sub

The easiest method of capturing the exact text to use is by placing a breakpoint at the beginning of the select case statement. Then once the code is paused, use the immediate window to type “? PromptString” and then press Enter.  You can the cut and paste the prompt into the code.

Advanced Method: If you want to try a more advanced method, it would be possible to get the message resource (if you know the Message ID) from Dexterity using passthrough sanScript and returning the result to the SY_User_Object_Store (SY90000) DUOS table and then reading the DUOS from VBA. Comparing against the message from Dexterity itself will always work regardless of language.

This is a good method of having a single set of code that will work for all languages. However, it is likely that each language is going to have its own application folder and so you can have separate code for each language as well.

Have fun customizing.


This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on http://www.winthropdc.com/blog.

3 thoughts on “Handling Translation when Customizing with VBA

  1. Hi David,
    It’s been a series of very useful information and concepts. Thank you for consolidating all these information and present it to us.
    And for this last article, a special Thanks, as this is imperative to consider on our customizations.


Please post feedback or comments

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.