This post explains how to use Microsoft Office Word's Mail Merge functionality to Import Data into Microsoft Dynamics GP. This method can be useful when working with master records or transactions not supported by any of the existing tools such as Integration Manager, eConnect or Web Services.
When attempting to import data into Microsoft Dynamics GP for a master record or transaction not supported by the usual tools, the usual option left is to perform a direct table import via the built-in Import Utility or using SQL Server tools such as Data Transformation Services (DTS) and Bulk Copy (BCP). The problem with a direct table import is that it bypasses all the application business logic and that the resulting data created could not be 100% correct. This could then cause issues later when using the application with the imported data.
The method described in this article uses Word's Mail Merge functionality to combine a recorded macro with a data set to create a new Macro file with will then enter the required data as though it was being entered by the user.
Note: This method works well when the entry of each record is identical. If additional dialogs are displayed or different actions are required to import the transactions, the macro would not handle this. It would be possible to use Word's IF conditional field functionality to make a macro which could handle these more complex situations, however that is beyond the scope of this article.
To demonstrate the method, this article will show how to import Sales Prospects into the Sales Prospect Maintenance window. Below are the contents of the comma delimited source data text file:
Prospect ID, Customer Name, Contact Person, Address 1, Address 2, Address 3, City, State, ZipPROSPECT 1, Name 1, Person 1, Address Line 1, Address Line 2, Address Line 3, City 1, State 1, 00001PROSPECT 2, Name 2, Person 2, Address Line 1, Address Line 2, Address Line 3, City 2, State 2, 00002
The steps to import this data into Sales Prospect Maintenance are shown below:
STAGE A: Create Template Macro
# DEXVERSION=XX.XX.XXXX.0 2 2CheckActiveWin dictionary 'default' form 'SOP_Prospect_Maintenance' window 'SOP_Prospect_Maintenance' NewActiveWin dictionary 'default' form 'SOP_Prospect_Maintenance' window 'SOP_Prospect_Maintenance' ActivateWindow dictionary 'default' form 'SOP_Prospect_Maintenance' window 'SOP_Prospect_Maintenance' MoveTo field 'Prospect ID' TypeTo field 'Prospect ID' , 'PROSPECT ID' MoveTo field 'Customer Name' TypeTo field 'Customer Name' , 'Name' MoveTo field 'Contact Person' TypeTo field 'Contact Person' , 'Contact' MoveTo field 'Address 1' TypeTo field 'Address 1' , 'Address Line 1' MoveTo field 'Address 2' TypeTo field 'Address 2' , 'Address Line 2' MoveTo field 'Address 3' TypeTo field 'Address 3' , 'Address Line 3' MoveTo field City TypeTo field City , 'City' MoveTo field State TypeTo field State , 'State' MoveTo field Zip TypeTo field Zip , 'Zip' MoveTo field 'Save Button' ClickHit field 'Save Button'
STAGE B: Create Word Mail Merge Document (based on Word 2007)
The resulting document should look like the following example:
# DEXVERSION=XX.XX.XXXX.0 2 2ActivateWindow dictionary 'default' form 'SOP_Prospect_Maintenance' window 'SOP_Prospect_Maintenance' NewActiveWin dictionary 'default' form 'SOP_Prospect_Maintenance' window 'SOP_Prospect_Maintenance' ActivateWindow dictionary 'default' form 'SOP_Prospect_Maintenance' window 'SOP_Prospect_Maintenance' MoveTo field 'Prospect ID' TypeTo field 'Prospect ID' , '«Prospect_ID»' MoveTo field 'Customer Name' TypeTo field 'Customer Name' , '«Customer_Name»' MoveTo field 'Contact Person' TypeTo field 'Contact Person' , '«Contact_Person»' MoveTo field 'Address 1' TypeTo field 'Address 1' , '«Address_1»' MoveTo field 'Address 2' TypeTo field 'Address 2' , '«Address_2»' MoveTo field 'Address 3' TypeTo field 'Address 3' , '«Address_3»' MoveTo field City TypeTo field City , '«City»' MoveTo field State TypeTo field State , '«State»' MoveTo field Zip TypeTo field Zip , '«Zip»' MoveTo field 'Save Button' ClickHit field 'Save Button'
STAGE C: Running the Macro to Import the data
Note: You might need to uncheck the "Hide extensions for known file types" folder option to be able to rename the extension.
Please consult the online help documentation for Word if you have any questions about how the Mail Merge functionality works.
This is a technique that can be used when there is no eConnect or Integration Manager alternatives.
David
Ref: Internal KB 953437
Posting from the Dynamics GP Blogster
http://dynamicsgpblogster.blogspot.com/2008/10/developing-for-dynamics-gp-weekly_30.html
Posting from DynamicAccounting.net
http://msdynamicsgp.blogspot.com/2008/10/word-mail-merge-and-macros.html
Exceptional post David-thanks!
Do you find it helpful to enter more than 1 records worth of data when recording the macro...just to make sure it keeps going, then you take the second part to do the mail merge?
Just curious. Thanks for a great post!
Chris
Hi Chris
While you could record the macro while entering a couple of records to confirm that the macro is the same, I would recommend that the final macro you use for your mail merge is a single record only.
Hi David:
then other this method, Are there any other ways to complete the import data?
Post from Jivtesh Singh at About Dynamics, Development and Life
www.jivtesh.com/.../dynamics-gp-customizations-best.html
Posting from John Lowther at Microsoft Dynamics GP DBA
community.dynamics.com/.../how-to-use-word-mail-merge-and-macros-to-import-data-developing-for-dynamics-gp-site-home-msdn-blogs.aspx
PLEASE READ BEFORE POSTING
Please only post comments relating to the topic of this page.
If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.