Microsoft Dynamics GP Developing for Dynamics GP
A blog dedicated to the Microsoft Dynamics GP Developer & Consultant community
 
Welcome to MSDN Blogs Sign in | Join | Help

Developing for Dynamics GP

by David Musgrave (Australia) and the Microsoft Dynamics GP Developer Support Team (USA)

News

  • Please use the Blog Feedback? - Contact Us link at the top of the page to email questions relating to the blog itself.

    If you wish to ask a technical question, please use the links below to ask on the Newsgroups. If you ask on the Newsgroups, others in the community can respond and the answers are available for everyone in the future.

    Please do not use comments on pages and posts to ask questions unrelated to the topic on that page or post.



    Dates of Interest:

    11-Jul-2008: Blog Created by David Musgrave.
    10-Oct-2008: First Post by Scott Stephenson.
    04-Nov-2008: First Post by Dave Dusek.
    11-Nov-2008: First Post by Beth Gardner.
    28-Nov-2008: First Post by Chris Roehrich.
    30-Dec-2008: First Post by Patrick Roth.
    24-Feb-2009: First Post by Greg Willson.
    22-Apr-2009: First Post by David Clauson.
    04-May-2009: First Post by Ryan Wigestrand.
    19-Jun-2009: First Post by Dawn Langlie.
    03-Jul-2009: First Post by Emily Halvorson.



    WorldMaps Statistics since
    24-Feb-2009:






    Translator Tool:




    Disclaimer

    This blog is provided "AS IS" with no warranties, and confers no rights.

    The links in this blog may lead to third-party Web sites. Microsoft provides third-party resources to help you find customer service and/or technical support resources. Information at these sites may change without notice. Microsoft is not responsible for the content at any third-party Web sites and does not guarantee the accuracy of third-party information.

Contents

Favourite Posts

Blog Links

Newsgroups Links

Resources Links

VBA - Running VBA scripts after Login or before Logout Example

Sometimes you need to run VBA (Visual Basic for Applications) scripts after a successful login attempt.  Using the OK Button on the Company Selection window does not always work as the login could still fail. For example, the user is already logged into the selected company. Also this does not help capture the logging out.

In v7.50 of Great Plains and earlier you could add the Toolbar window to VBA and run scripts on the Window_AfterOpen() or Window_BeforeClose() events. From v8.00 onwards, the change in the menu navigation model means that the Toolbar window is no longer visible and so cannot be added to VBA.

Even though the Toolbar window cannot be added to VBA using the Tools >> Customize >> Add Current Window to Visual Basic menu option, you can import a blank Toolbar package to add the window and the main fields to VBA.

Below are the steps to create a generic Toolbar package which can be used to expose the current User, Company Name and User Date.  This information can be retrieved using the RetrieveGlobals.dll (v8.0), RetrieveGlobals9.dll (v9.0) or UserInfoGet object (v10.0). It can also be used to execute VBA code just after logging in, which is what we need it for.

1) Use Notepad.exe to create a text file on your Desktop called Toolbar.txt and copy the text below into it.

<Component Name="Toolbar" ProductId="0" Object="VBAForm" >
VBAForm "Toolbar"
{
 Windows
 {
  Window "Main_Menu_1"  
  {
   EventMode "0"
   Fields
   {
    WindowField "(L) eEnterpriseUser ID"    
    {
     ArrayIndex "0"
     DisplayName "eEnterpriseUserID"
     Local "true"
     ProgrammerName "eEnterpriseUser ID"
    }
    WindowField "Company Name"    
    {
     ArrayIndex "0"
     DisplayName "CompanyName"
     Local "false"
     ProgrammerName "Company Name"
    }
    WindowField "Date"    
    {
     ArrayIndex "0"
     DisplayName "UserDate"
     Local "false"
     ProgrammerName "Date"
    }
   }
   Title "Toolbar"
  }
 }
}
</Component>

2) Save the file and exit Notepad.exe. 

3) Rename the Toolbar.txt to Toolbar.package.

NOTE: To be able to rename the extension, you might need to display the file extensions if they are hidden. From a Windows Explorer window, use the menus to open the Folder Options window and on the View tab, uncheck "Hide extensions for known file types". Then click OK.

Now we can import the generic Toolbar package we created.

4) From Microsoft Dynamics GP menus click Tools, click Customize, click Customization Maintenance.

5) Click Import, click Browse and select Local. Find the Toolbar.package file and click open. Then click OK.

6) From the menu click Tools, click Customize, click Visual Basic Editor.

7) In the Visual Basic Editor, locate the Toolbar(Window) module under the Microsoft_Dynamics_GP project. Double click on the module and add the desired scripts. 

Now you know the steps, I have just opened the microwave and found a Toolbar.package I made earlier and have attached it to this post.

The package which works for v8.0, v9.0 & v10.0 is attached at the bottom of the article.

Posted: Tuesday, July 29, 2008 10:28 AM by David Musgrave
Filed under:

Attachment(s): Toolbar.zip

Comments

Developing for Dynamics GP said:

Microsoft Dynamics GP remembers the last user to use the application and defaults the User ID into the

# July 28, 2008 10:16 PM

Developing for Dynamics GP said:

A while back I did a post on running Visual Basic for Applications (VBA) scripts when logging into and

# April 10, 2009 3:46 AM

Developing for Dynamics GP said:

A while back I did a post on running Visual Basic for Applications (VBA) scripts when logging into and

# April 15, 2009 9:02 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker