Christian, Lorraine
LChristian at MassMutual.com
Tue Feb 5 18:09:49 CST 2008
Sorry forgot to send this unsecure. -----Original Message----- From: Christian, Lorraine Sent: Tuesday, February 05, 2008 3:10 PM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Automation of word Hi there - Not sure if this will help anyone. The document already points to the datasource. This function is called from a command button on a form Private Sub cmdOnePage_Click() MailMergeIt "FinalOnePageMergeDoc.doc", acViewPreview End Sub ----------------------------------------------------------------------- Public Function MailMergeIt(NameOfDoc As String, ViewOrPrint As Integer) On Error GoTo ErrMM Dim strPath As String Dim objWord As Object Dim lngCount As Long Dim blnCreated As Boolean strPath = "Y:\PathHere\MergeDocHere.doc" 'check to make sure data exists lngCount = Nz(DCount("*", "qysMailMergeData"), 0) 'The query that holds the data If lngCount = 0 Then MsgBox "No data for mail merge.", vbOKCancel + vbCritical, "No Data Found..." Exit Function Else MsgBox "There are " & lngCount & " letters in this mail merge. This will take a few minutes.", vbOKOnly + vbInformation, "Letter Count" Set objWord = GetObject(strPath) objWord.MailMerge.Execute objWord.Application.ActiveDocument.SaveAs filename:="Y:\apps\BKMailMerge\MailMerge\MergeDocsPDFs\" & _ "WordMerge" & Format(Date, "mmddyy") & ".doc" If blnCreated = True Then objWord.Close End If Set objWord = Nothing End If MsgBox "Mail merge completed and your document has been saved. You can proceed to Step 3.", vbOKCancel + vbInformation, "Letter Generation" ExitMM: Exit Function ErrMM: Select Case Err.Number Case Else MsgBox Err.Number & " - " & Err.Description Resume ExitMM End Select End Function Lorraine -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo Sent: Tuesday, February 05, 2008 5:38 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Automation of word You can open Word and set it to background printing and then keep it open until printing is completed and then close it down. Is that what you are after? Max -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Monday, February 04, 2008 4:16 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Automation of word Rocky, In fact the method I am using is to export the data into t text file. The word document is then "hard coded" to pull in data from that text document. I just open the word document and it "just does it". Of course I have to successfully export the data to the text file first. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at Beach Access Software Sent: Monday, February 04, 2008 10:32 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Automation of word John: Can't help you with that but I'm curious to know the code you're using to do the merge. I had a merge function and it used to work. Now, for reasons I have yet to be able to figure out it doesn't. My code to open the document and merge is only a few lines: Dim objWordDoc As Word.Document Dim objWord As Object Set objWord = CreateObject("Word.Application") With objWord 'Visible is set True in order to view the operation. .Visible = True .Documents.Open (strDocName) .ActiveDocument.MailMerge.Destination = wdSendToNewDocument .ActiveDocument.MailMerge.SuppressBlankLines = True .ActiveDocument.MailMerge.Execute End With It starts word and opens the document just fine but at .ActiveDocument.MailMerge.Destination = wdSendToNewDocument I get requested object not available. How are you opening and merging your document? TIA Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Monday, February 04, 2008 6:49 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Automation of word I have a rather elaborate mail merge system in a client's system. ATM I open the document, merge the date and the user takes over, filling in things that they need to fill in, then printing and closing the word instance. It works well enough however I do not control the save of the document, and very occasionally Word does not close cleanly, leaving a hidden instance open WITH the associated merge text document open as well, preventing the next merge from occurring. I need to know if it is possible to open word in a mode that prevents it from being closed by the user? I would then have the user go back to my application and press a button saying that they succeeded in doing the mail merge. I would save the document and close Word down. Can I prevent the user from closing Word? John W. Colby Colby Consulting www.ColbyConsulting.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.19/1257 - Release Date: 2/3/2008 5:49 PM -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com --------------------------------------------------------- This e-mail transmission may contain information that is proprietary, privileged and/or confidential and is intended exclusively for the person(s) to whom it is addressed. Any use, copying, retention or disclosure by any person other than the intended recipient or the intended recipient's designees is strictly prohibited. If you are not the intended recipient or their designee, please notify the sender immediately by return e-mail and delete all copies. ---------------------------------------------------------