Microsoft CRM Houston
(800) 892-6143

Your Full Name:                  Your e-mail                   Comments

Implementation & Customization Setup the mail merge template to be used with custom mail merge program:

1) Open Microsoft Word 2003 (this works and has been tested for MS Word 2007 but directions are written for 2003....menu options may be different)
2) File->New
3) File->Save As: Change Type to "Document Template",change location to c:\, name the file MCRM004.dot, press SAVE
4) View->toolbars->Mail Merge
5) On the mail merge tool bar, click on the button for "open datasource" (hover over the button for a description).
6) Click on the "New Source" button in "Select Data Source" window that opens after step 5
7) Select "Microsoft SQL Server" and click next
8) Input the name of your SQL Server
9) Make sure that "Use Windows Authentication" is selected, click next (also make sure the current user you are logged in under is a user within the related CRM system, otherwise this will not work)
10) Select your CRM Database in the picklist, scroll to the view or table you want to use, select it and click next (views appear first then tables) (contactbase is used in this example).
11) Name it whatever you want .odc, click finish (this example will use "_CONTACTBASE.ODC")
12) The "Select Data Source" window will appear after step 11. Right click the file name "_CONTACTBASE.ODC" and click copy, navigate to the c:\ and paste the file in. Highlight the c:\_CONTACTBASE.ODC" file and click open.
13) The "Confirm Data Source" window will appear, click OK
14) Go back to the mail merge toolbar and find the button for "Insert Merge Fields", click that button and select "firstname" from the list. (Not to be confused with "Insert Word Field" option on the toolbar, also if you don't see "firstname" make sure that you didn't accidentally select the contract table in step 10)
15) You should now see <<FirstName>> in your word document. Click the save button and close.


Code Steps:

1) Open notepad and copy in the following code, save the file as an .htm file

 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

<title>Word Mail Merge</title>

</head>

<body>

<script type="text/vbscript">

Dim wordDoc

Dim wordApp

Dim SQLStatement

SQLStatement = "select top 5 firstname from contactbase where lastname like '%j%'"

Set wordApp = CreateObject("Word.Application")

wordApp.Visible = True

Set wordDoc = wordApp.Documents.Open("c:\MCRM004.dot")

wordDoc.MailMerge.OpenDataSource "c:\_CONTACTBASE.odc", , , , , , , , , , , , SQLStatement

wordDoc.MailMerge.Execute

wordDoc.Close False

wordApp.Visible = True

window.close()

</script>

<%-- <form id="form1" runat="server">

<div>

</div>

</form>--%>

</body>

</html>

 

3) In the CRM website in IIS, add a new Virtual Directory beneath the CRM website.  Save the .htm file created above in the virtual directory

 

Notes:
1) The .dot and .odc files can be referenced from a shared location and using filtered views should prevent unauthorized access
2) The .odc file looks like it could handle editing directly into the document.

Training
Microsoft CRM 101
Microsoft CRM for Outlook
Microsoft CRM Advanced Find
Microsoft CRM Reports
Microsoft CRM Database
Microsoft CRM Web Services
Microsoft CRM JavaScript
Microsoft CRM Add-ons
Microsoft CRM Resources
Microsoft CRM Callouts
Microsoft CRM Workflow