다음을 통해 공유


Hybrid - Changing Screen Colours Depending on Company Example

This is one of my favourite examples mainly because it achieves something that most people thought was not possible with VBA. To be honest, it still is not possible with VBA alone.  This hybrid code uses the unsupported method of calling Dexterity sanScript from VBA to use the Dexterity commands to select and change colours.

This example was demonstrated at the Microsoft Dynamics GP Technical Airlift 2008 to show how you can have a Microsoft Dynamics GP for Barbie release, see screenshot below: 

Microsoft Dynamics GP for Barbie 

The Modifier is used to modify the form and create the additional buttons and fields needed.  Then VBA is used to add the scripting.  I created two VBA functions that do most of the work, SetColour and GetColour.  The SetColour function uses the Continuum Integration Library to execute Dexterity sanScript to set the background colours from values passed in.

The GetColour function is a bit more complex.  It also uses the Continuum Integration Library to execute Dexterity sanScript to open the colour selection dialog and store the results in the SY_User_Object_Store table. The SY_User_Object_Store table, which is the SY90000 table in the company database, is the table used for the VBA Dynamic User Object Store (DUOS) table.  As we are unable to pass parameters back from sanScript when executing it from VBA, we can store data in the DUOS table and then read that data from VBA as another method of returning data.  Storing the data in the DUOS serves a double purpose in this example, it allows the passing of the data back from Dexterity to VBA and stores the settings so they will be remembered next login.

The buttons on the Company Options window use these two functions to provide the user interface for the customisation. The final piece of the puzzle is the use of a Toolbar.package.  Even though the toolbar form is no longer visible in version 8.00 or later and so cannot be added to VBA, it can be added as a package and used to execute VBA code after login.  For our example, it is using the SetColour function to set the background colours for the current company based on the values read from the DUOS.

NOTE: This customisation uses a method of executing Dexterity sanScript code from VBA which is unsupported by Microsoft.

Example code for v8.0, v9.0 & v10.0 is attached at the bottom of the article.

Please see the "Installation Instructions.txt" file in each version's archive for more information.

WARNING: This posting and example contain International English spelling, use at your own risk. :-)

[Edit] Often this background colour example is wanted to help identify Test or Historical companies.  Please see the Setting up Test and Historical Companies post for how to have a dialog pop up during login as well.

[Edit] This feature is now available from Administrator Settings window of the Support Debugging Tool for Microsoft Dynamics GP, have a look at the Support Debugging Tool Build 11 released post for more info.

17-Mar-2009: Added link to Test and Historical Company post.

05-Jun-2009: Added link to Support Debugging Tool Build 11.

Colours Depending on Company.zip

Comments

  • Anonymous
    July 24, 2008
    PingBack from http://blogs.msdn.com/developingfordynamicsgp/pages/modifier-vba-samples.aspx

  • Anonymous
    August 04, 2008
    Posting from DynamicAccounting.net http://msdynamicsgp.blogspot.com/2008/07/make-sure-you-are-reading-david.html

  • Anonymous
    October 01, 2008
    I did not start this thread, but I thought I would give a bit of insight into the subject. Vaidy Mohan

  • Anonymous
    February 26, 2009
    From the Translating Dexterity Applications Series . The final topic in the series is one that was added

  • Anonymous
    February 26, 2009
    From the Translating Dexterity Applications Series . The final topic in the series is one that was added

  • Anonymous
    April 07, 2009
    When I try to import the package I get error: Cannot import package because the required customization tools are not registered. What am I missing?

  • Anonymous
    April 07, 2009
    Hi here4real You must have the Modifier with VBA or the Customisation Site License registered to be able to import packages with Modified forms or VBA. This customisation will be available in the next Support Debugging Tool build... coming soon. David

  • Anonymous
    June 04, 2009
    The comment has been removed

  • Anonymous
    December 12, 2009
    if i want to change the trigger when the user login, the applycolors is running, how could i do that? what i must change on the code? thanks.

  • Anonymous
    December 13, 2009
    Hi SomeOne I am not quite sure what your question is. The colour changing code already runs at login. The following post has more information on how to run code at login and logout: http://blogs.msdn.com/developingfordynamicsgp/archive/2008/07/29/vba-running-vba-scripts-after-login-or-before-logout.aspx David PS: The Support Debugging Tool now has the colour changing feature built in to it.

  • Anonymous
    September 30, 2010
    When using this how does the Application Color work?  I have it setup in my test environment on the Fabrikam company and the only place the color shows up is the windows.  I set the application to a light pick and the window to a light blue.   I only see the light blue.  

  • Anonymous
    September 30, 2010
    Hi Tammy The way the application background was used has changed now that the home page is covering it up. Can I suggest not using this code anymore. Instead, install the Support Debugging Tool which has a much more up to date functionality to color code companies. David

  • Anonymous
    September 19, 2012
    Hi David, Is there a way to copy colors out without running the debugger tool on every machine?  We are doing a test upgrade and we would like to differentiate GP 10 from GP2010.  Both versions are install on each machine.  We don't need to differentiate each company, just the install itself.  However, once we're done, we need to remove the colors from all the machines. Thanks, Clark

  • Anonymous
    September 19, 2012
    Hi Clark To get the color coding to work on every workstation you will need code on every workstation. The Support Debugging. Tool is worth installing on all workstations with a shared setup file anyway as it has many other features to help administer and support Dynamics GP. See the following post: blogs.msdn.com/.../21-reasons-why-every-workstation-should-have-the-support-debugging-tool-installed.aspx David