Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i create a button on a form to mail merge

Status
Not open for further replies.

ally

Technical User
Jul 17, 2000
3
GB
I've created a query which lists patients names and address' that havn't visited a surgery between two dates. What i want now is to create a button which mail merge's this information into a letter in MS word (so that the letter can be altered if necessary). <br>Any suggestions would be helpful,<br>Cheers<br>Ally
 
this is from DougP's FAQ on Opening Word and running a Mail Merge, I just removed the running of a Macro from it.<br><b><br>Private Sub Command19_Click()<br>On Error GoTo Err_Command19_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;' Button launches Word and opens a specified document<br>&nbsp;&nbsp;&nbsp;&nbsp;' And runs an optional macro. the macro could print out the word doc and quit<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim retval As Variant<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim DocName As String<br>&nbsp;&nbsp;&nbsp;&nbsp;'Dim MacroName As String<br>&nbsp;&nbsp;&nbsp;&nbsp;' Drive and Full path to name and location of Word document<br>&nbsp;&nbsp;&nbsp;&nbsp;DocName = &quot;C:\My Documents\MyDoc.doc&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'Optional Macro Name. Note Word Macro name cannot have any spaces in it.<br>&nbsp;&nbsp;&nbsp;&nbsp;'MacroName = &quot;/M&quot; & &quot;MacroName&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'Note full path to Word including Drive and folder<br>&nbsp;&nbsp;&nbsp;&nbsp;retval = Shell(&quot;c:\Microsoft Office97\Office\WinWord.exe&quot; & &quot; &quot; & DocName, vbNormalFocus)<br><br>Exit_Command19_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br><br>Err_Command19_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Err.Description<br>&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_Command19_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End <br></b><br><br>of course, you could also write the whole letter in VB if you wish. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top