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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening current info to new Word mail merge

Status
Not open for further replies.

famousb

Programmer
Mar 2, 2000
239
0
0
US
I can seem to manage to get Word to open fine through code, and to open to the Mail Merge helper fine, but i want to be able to automatically have Word open a new document as a mail merge with the data on my form (as limited by a query/filter) be the default data for the mail merge. <br>
<br>
anyone have any suggestions for this? <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
you can CAll a Word doc thats already got a mail merge set up and automatically merge it and then print it and then close it <br>
Is that what you want to do?<br>
First Create your Word Doc and connect it to your Access query.<br>
Your Access query will look at a specific field on a form.<br>
then you will have a Command button that launches Word and opens the doc and also runs a Word macro.<br>
The macro will print the doc to a specified printer and Quit Word.<br>
In word the Mial merge button on the Word Doc needs to have the &lt;&lt;ABC&gt;&gt; button depressed so it will merge automatically.<br>
<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
This is basically the code that i am using so far: <br>
<br>
Dim oApp As Object<br>
Dim objWord As Object<br>
Set oApp = CreateObject(&quot;Word.Application&quot;)<br>
oApp.Visible = True<br>
<br>
Set objWord = CreateObject(&quot;Word.Basic&quot;)<br>
objWord.FileNew<br>
<br>
this creates a new Word document, I want the end user to be able to type a new Word document, and to have the mail merge refer to the set of data that was on the form in Access. The end user needs to be able to create the new document because there are constantly new letters being generated. there is no one default letter.<br>
<br>
I guess what i need to know is how to define a Word macro to identify the new document as a mail merge and also have the macro set the data from the form as the source data. i could place this after the last line of the code above to have it run after the document opened. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
See My Example Below that I got from the posting here. But when I click on the Print Button it is saying &quot;file not found&quot; I have checked and rechecked the file path name but still same error. Can anyone else help. Thanks in advance.
__________________________________________________________

Private Sub PrintSPLetter_Click()

On Error GoTo Err_PrintSPLetter_Click

Dim retval As Variant
Dim DocName, BuildWordInfo As String
' The document name can be gotten from anywhere including Combobox, ListBox, Subform
DocName = &quot;G:\Access\AmeriForms\ADLetter.doc&quot;

'Optional Macro Name
MacroName = &quot;ADLetterMacro&quot; ' <<< Macro name cannot have any spaces in it.

' Launch Word

BuildWordInfo = &quot;C:\Program Files\Microsoft Office\Office10\WinWord.exe&quot; & DocName & MacroName
retval = Shell(BuildWordInfo, 1)

Exit_PrintSPLetter_Click:
Exit Sub

Err_PrintSPLetter_Click:
MsgBox Err.Description
Resume Exit_PrintSPLetter_Click

End Sub
 
wabeg,

Without testing it myself, try placeing extra spaces in the line :

BuildWordInfo = &quot;C:\Program Files\Microsoft Office\Office10\WinWord.exe&quot; & DocName & MacroName


I think it should be:

BuildWordInfo = &quot;C:\Program Files\Microsoft Office\Office10\WinWord.exe &quot; & DocName & &quot; &quot; & MacroName

Notice I placed an extra space after winword.exe and added one after DocName.
 
That worked like a charm. Now how do you get the word doc to print out the letter. The macro that I recorded didn't run but the letter opened up. I want to automate the whole process to the point where Word closes after the merged record print. Is it possible I might not be setting up the macro correctly?

Thanks.
 
Ok got the macro to work as well on my PC. But when I tried to show it to my boss the Access stops on the Macro event:

MacroName = &quot;/M&quot; & &quot;ADLetterMacro&quot;

I am think since the macro was done my pc how can I make it so it will work for everyone.
 
Ok got the macro to work as well on my PC. But when I tried to show it to my boss the Access stops on the Macro event:

MacroName = &quot;/M&quot; & &quot;ADLetterMacro&quot;

I am think since the macro was done my pc how can I make it so it will work for everyone.

Oh yeas the document is sitting on a network share the file (word doc) is not local to my PC.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top