Using Mail Merge Macro in Dynamics GP

By Allen Phillips | August 30, 2018

Using mail merge macro in dynamics gp

One way to automate the manual entry process is to use a Mail Merge Macro in Dynamics GP. This method will allow the user to enter data into a spreadsheet and then create a macro to input the data into any Window. This method requires some advanced Microsoft Office expertise and can be problematic if the data in the spreadsheet is not set up properly, however, it will be much faster than manually typing all records into the Window.

The following example only references the Sales Transaction Entry Window. Although it is possible to enter multiple Tab data all in one macro, it only increases the likelihood of data errors. It is also important to populate all lookup tables prior to the Mail Merge process. NOTE: All data in the import spreadsheet MUST match the exact spelling of the data in each of the corresponding lookup tables. Be careful and make sure that there are no hidden spaces at the end of a record. This Macro is based on opening each sales record and refreshing the Tax Information as an example.

Mail Merge in GP

A spreadsheet with column headers that match each field name should be used, an example is shown below:

Mail Merge in GP

The above sample spreadsheet an example.

Step 1:

Create a Dynamics GP Macro that will show the data entry into all of the fields that match the data entry spreadsheet.  Open the Sales Transaction Entry window then click Tools> Macro> Record.

Mail Merge in GP

Then immediately begin the data entry process starting at the Document No. field use the Tab key to switch from one field to the next.  As soon as the data entry is complete for the document, then click Tools> Macro> Stop.  Save the Macro file with a name and location that can be easily located.

Step 2:

Open the text of the Macro in Microsoft Word.  Below is an example of what the macro may look like:

# DEXVERSION=16.00.0034.000 2 2
CheckActiveWin dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
  TypeTo field 'SOP Number' , 'WEBQTE001710'
  MoveTo field 'Customer Number' 
  MoveTo field 'Expansion Button 10' 
  ClickHit field 'Expansion Button 10' 
NewActiveWin dictionary 'default'  form 'SOP_Summary_Tax_Entry' window 'SOP_Summary_Tax_Entry' 
  CommandExec dictionary 'default'  form 'SOP_Summary_Tax_Entry' command 'Default Button_w_SOP_Summary_Tax_Entry_f_SOP_Summary_Tax_Entry' 
# Resetting these defaults will delete all current entries.  Are you sure you want to delete the existing entries?
NewActiveWin dictionary 'default'  form DiaLog window DiaLog 
  ClickHit field OK 
NewActiveWin dictionary 'default'  form 'SOP_Summary_Tax_Entry' window 'SOP_Summary_Tax_Entry' 
  CommandExec dictionary 'default'  form 'SOP_Summary_Tax_Entry' command 'OK Button_w_SOP_Summary_Tax_Entry_f_SOP_Summary_Tax_Entry' 
NewActiveWin dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
  CommandExec dictionary 'default'  form 'SOP_Entry' command 'Save Button_w_SOP_Entry_f_SOP_Entry' 
  MoveTo field 'SOP Number'

Notice that each of the steps in the macro represents the movement to a field and the data that was entered.  The goal is to program Microsoft Word to recognize the data entered as a column in the import spreadsheet.

Step 3:

The first line of the macro must be deleted temporarily.  The first line is a header that can only appear as the first line of the macro.

The following instructions apply when using MS Word 2016.

Click the Mailings menu then click the Start Mail Merge button and select Step by Step Mail Merge Wizard

Mail Merge in GP

Select the document Type of Directory then click Next: Starting Document.

Mail Merge in GP

Select Use Current Document then click Next: Select recipients.

Mail Merge in GP

Select Use an existing list then click the browse button.

Mail Merge in GP

Browse to the location of the Excel spreadsheet that contains the import data.

Each worksheet of the spreadsheet will appear on the list.  Select the appropriate worksheet then click OK.  Note the checkmark for the First Row of data contains column headers.

Mail Merge in GP

The column headers and the data from the worksheet will appear in the list.

After the spreadsheet has been selected, Click Next: Write Your Letter

Highlight the Document No. data then click More Items

Mail Merge in GP

Select Document No. from the Insert Merge Field list, then click the Insert button then Close the Insert Merge Field window.

Mail Merge in GP

Then click Next: Preview your directory

The first record from your import spreadsheet will be entered into the document.


Mail Merge in GP

If the records are not accurate, then repeat the steps above to try and locate the problem.

Click Merge To New Document…

Select All or a range of records to merge then click OK

Mail Merge in GP

It is necessary to paste the first line of text from the macro into the top line of the new document:

Mail Merge in GP

Finally, save the document as a plain text document.

Rename the document using a suffix of .mac for example TaxUpdate.mac

The final Step is to open Dynamics GP then Open the Sales Transaction Entry window and select Tools > Macro > Run and run the TaxUpdate.mac file that has just been created.

After the Macro runs successfully, all records will be in the database. If there is an error, then the line on which the error occurred will be displayed in the error message as shown below:

Mail Merge in GP

If an error is encountered, it will be related to the data on the line indicated. Make the necessary data correction and rerun the macro.

NOTE: Records can only be imported once so if records were successfully imported, then they will need to be removed from the macro before attempting to run it again.

Related Posts

Recommended Reading:

5.27.22 Dynamics GP

How to Run Drop Ship Sales in Dynamics GP

Need to Invoice the Customer before you get the invoice from the vendor? This The freight forwarder has contacted you […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Protecting G/L Accounts From Being Deleted

There are a lot of exciting New Features in Dynamics 365 Business Central 2022 Wave 1 Release to get excited […]

Read the Article
5.25.22 Financials

Rounding Numbers in Power Automate

  If you’ve ever tried to round numbers in Power Automate, you have probably already run into the issue there […]

Read the Article

Manage U.S. Use Tax on Purchase Orders in Dynamics 365 Finance and Operations

  Managing sales tax requirements on your business purchase can be complicated, but Dynamics 365 Finance and Operations can help […]

Read the Article
5.19.22 Dynamics CRM

How to Write a Great Support Ticket in the Stoneridge Support Portal

Submitting a support ticket through the Stoneridge Support Portal is a quick and effective way to get assistance for any […]

Read the Article

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!