How to use macros and Scheduled Tasks to automatically start the program and to do other tasks in Microsoft Dynamics GP

This article discusses how to create and how to run macros to do various tasks in Microsoft Dynamics GP and in Microsoft Business Solutions - Great Plains.

Applies to:   Microsoft Dynamics GP
Original KB number:   856496


The macros can be used to automatically start the program, to generate reports, and to do other tasks. This article also discusses how to use Scheduled Tasks to run the macros.

More information

  1. To create and to run a macro that automatically generates reports or that does other tasks, follow these steps:

    1. Start Microsoft Dynamics GP. Don't sign in.

    2. In the Welcome to Microsoft Dynamics GP dialog box, press ALT+F8 to start recording the sign-in macro. Name the macro, and then save it to the installation folder for Microsoft Dynamics GP.


      If the macro isn't in the installation folder, you will receive the following error message:
      Cannot open macro

    3. In the Server box, select a server.


      It's important to select the appropriate server when you create the macro, even if the correct server was selected when you started Microsoft Dynamics GP.

    4. In the User ID field, enter the appropriate information for the user who will generate the report or who will generate other tasks.


      • It's important to do this step when you create the macro, even if the correct user ID is displayed when you start Microsoft Dynamics GP.
      • To make sure that the desired user ID is recorded within the macro, we recommended that you delete any existing user ID from the field, move to the Password field, return to the User ID field, and then enter the desired ID.
    5. In the Password field, type the password for the user who is selected in step 1d.

    6. Select OK. The Company Login dialog box opens.

    7. From the Company list, select the company for which you want to sign in, and then select OK.


      It's important to select the appropriate company when you create the macro, even if the correct company is selected when the Company Login window opens.

    8. Complete all the steps that are required to process the reports or other tasks within this company.

    9. On the File menu, select Exit to close Microsoft Dynamics GP.

  2. Use a text editor, such as Notepad, to add the following line as the second line of the macro.

    Logging file 'macro.log'


    This line prevents any message that is displayed by the macro from being displayed. Therefore, such a message cannot prevent a logon to Microsoft Dynamics GP. An example of such a message is the total run time of the macro. All messages that are generated by the macro are written to the Macro.log file.

  3. To start Microsoft Dynamics GP by using the macro, create a batch file. To do it, follow these steps:

    1. Create a file that has a .bat file name extension. For example, create a file that is named DynamicsGP.bat.

    2. Use a text editor, such as Notepad, to open the batch file.

    3. Paste the following line into the .bat file.

      dynamics dynamics.set XXX.mac cd c:\Dynamics GP installation path


      Replace XXX.mac with the name of the macro file that you assigned in Step 1b. Replace Dynamics GP installation path with the installation path of Microsoft Dynamics GP on this computer. For example, type the following path:
      Program Files\Microsoft Dynamics\GP

    4. Save the changes, and then close the batch file.

  4. Configure Scheduled Tasks to run the batch file that will run the macro that you created. For more information about how to use Scheduled Tasks, see the Windows manuals or Windows online documentation.