o
k
q
u
e
s
t
i
o
n
s
.
c
o
m

***Resolved*** Mailmerge Problems Again -

I am trying to do a Word mailmerge from VB taking the Receipt data from an Access 97 Table. The code that I am trying to use opens my mailmerge document allowing me to view it in Word before printing it. Although I'm sure the code has errors in it and has lots of room for improvement, it does work.

However, upon closing Word and returning to my application it crashes if I try to do another mailmerge without closing my application. Tells me that VB has caused a fault in Kernal32.dll.

Usually can't get rid of the error and have to reboot. As long as I don't try to do another mailmerge before closing the application everything else works ok so it has to do with this code. I have included the code I'm using below.

Private Sub cmdPrintReceipts_Click()

Dim Filename1 As String
Dim oMyWordApp As Object
Dim oWordDoc As Object

Set oMyWordApp = CreateObject("Word.application")
oMyWordApp.Application.Visible = True
Filename1 = App.Path + "\Receipt_Letter.Doc"
oMyWordApp.Documents.Open Filename1

Set oWordDoc = oMyWordApp.ActiveDocument
oWordDoc.MainDocumentType = wdFormLetters

oWordDoc.MailMerge.OpenDataSource _
Name:=App.Path + "\GCDistribution.mdb", _
LinkToSource:=True, _
AddToRecentFiles:=False, _
Connection:="TABLE Receipts", _
SQLStatement:="Select * from [Receipts]"

oWordDoc.MailMerge.Destination = wdSendToNewDocument
oWordDoc.MailMerge.Execute

'Close the original document and make Word visible so that
'the mail merge results are displayed
oWordDoc.Close False
oMyWordApp.Visible = True

'Prevent save to Normal template when user exits Word
oMyWordApp.NormalTemplate.Saved = False

Set oMyWordApp = Nothing
Set oWordDoc = Nothing

Exit Sub

End Sub

Any help here would be appreciated,

I also have a couple of related questions. 1) When I preview this as it is doing now, how can I make it display iautomatically n Print Layout View instead of Normal View.

2) If I should later decide that I don't need to preview the merged documents before printing, what would I need to change to get it to open Word minimized and automatically print the merged documents and then close Word?

Thanks for your input.

Rev. Michael L. Burns

 

MailMerge problem. Urgent! -
I am having a problem that is how to reserve the marco after mailmerge. The situation is I have a template which contains the macro for later use. But first the fields in this template needs to be merged from an Excel file. After I merged the file and send it to a new document using


Is it possible to send mailmerge word doc through IE -
Hi, I was wondering if it is possible to send a mailmerge word file through the internet. What I'm doing is as follows: - user logs into website - user enters information and submit - website takes information and mailmerge with existing template - sends user end result No


***Resolved*** Mailmerge Problems Again -
I am trying to do a Word mailmerge from VB taking the Receipt data from an Access 97 Table. The code that I am trying to use opens my mailmerge document allowing me to view it in Word before printing it. Although I'm sure the code has errors in it and has lots of room for improvement,


Merge two tables into one document -
I have two tables. One is a list of clients, and one is a list of data to be sent to all clients. I want to use Word to mailmerge the two together, except that there doesn't seem to be a way to do it! Any ideas on the best way to go about this? Should I create a multipage documen


MailMerge with C# example -
I have been hunting for a mailmerge example using C#, and all I can find ix examples using VB, has anyone seen a C# example?


MailMerge Problems -
I have started having problems with MailMerge in my database - it has worked before but now I get this error: Runtime error 5922 "Word was unable to open data source" Here is my code: Code: Function MailMerge(strMMTemplate As String) Dim objWord As Word.Appl


[FAQ's: OD] How do I automate a Word MailMerge document -
Using the MailMerge object in the Word Object Model we can modify or execute a mailmerge on an existing mailmerge document. You may want to do this for reasons like filtering an output of records, sorting, changing a datasource (keeping the same fields), batch processing, etc. F


trying to create a macro that prints records -
ok, I'm trying to create a macro to print a record in work, then go to next record and then print it... and do this till the last record... what's wrong with my code? Help...... ************************************ Sub DoUntil() Check = True: ActiveDocument.MailMerge.DataSour


Try & figure this -
I have a general Word2000 document with fields linked to a dbf (dbase) file via MailMerge. I've now saved the Word document as an htm file. The fields still merge to the dbf file with IE's 'Edit with MS Word for Windows'. OK so far. But now I would like the htm page to MailMerge wi


Word MailMerge and VB 6 problem. -
Hello I am trying to send a mailmerge document to the printer after attaching the datasource file. See Code below. Code: Option Explicit Public WithEvents objWord As Word.Application Private Sub objWord_DocumentOpen(ByVal Doc As Word.Document) With Doc


VBA - mailmerge -
Hi, Im workin on a mailmerge-thing which merges with the Exchange addressbook and Im a little stuck... right now I have this code: Code: ActiveDocument.MailMerge.UseAddressBook Type:="olk" ActiveDocument.MailMerge.DataSource.QueryString = _ "


MS Word mailmerge automation -
Can anybody provide me with some sample code to automate the mailmerge function offered by MS Word from a Visual Basic program. Thanks for your help in advance.


mailmerge and recordset -
Can anyone tell me how to connect a loaded template doc with a mailmerge to a recordset ? im using the MSword9 object and vb6 sp4 Thanks anyway!!!


Mailmerge via ODBC -
How can I use an existing ADO recordset to create Word 2000 mailmerge documents?


mailmerge with a recordset -
Hi, i've seen plenty of examples of doing a Word mailmerge with a temporary table, but is it possible to do it with an ADODB recordset? I've seen this question asked many times and not answered yet so if anybody has a solution i reckon you would be helping many people out! Ch


Outlook Mailmerge using VBA -
Hi I have tried posting this at various other outlook forums, but never had a single reply (maybe that says more about my Q than the people in the forums. I am trying to produce a macro with VBA in Outlook (to assign to an outlook toolbar) to do the following: - when outlook i


Mailmerge & VB -
Hi everybody, Now, I try to use Word Mailmerge via VB. Basically, I have to create a main document which I already accomplished and setup the datasource which I can't. I want to create a datasource in VB code and want to connect the database via an ODBC. Is there anyone know how to


mailmerge from outlook to word -
can anyone tell me where i can get a simple code to setup an automated mailmerge from outlook contacts list ( select by category say ) to a single word form letter document. many thanks


open a mailmerge document -
Hello,I have searched the forum but couldn't find a solutuon to my specific problem.Actually I have created a mailmerge using microsoft word and as data source, i use a table from microsoft access.Every time i try to open the word document,I am given a msgbox telling me that opening th


Replace MailMerge -
ok this is my first stretch into vb.net so be gentle.... I want to open a word document that could look like something like this: Dear <CompanyName>, blah blah blah. I want to open this word document and replace the <CompanyName> tag with a mailmerge field. I can


Is it possible to do this -
I am trying to make a system for my user in which it prints out labels. The problem is that now I have my query (it selects everything that my user will need on his label), I want to try the following: Make a macro (either from Access or Word) that allows him to select only certain


Help Required Urgently:In Continuation of thread Id=234230 -
Please refer to thread following thread http://www.vbforums.com/showthread.p...hreadid=234230 The problem is whenever I try to open the .doc file for mail merge, it's throwing an error that word was unable to open datasource. wrd.Visible = True wrd.Documents.Ad


Data Types, and File Saving -
I am doing a forced mailmerge from access to a word document, the table in my database I am using to do the merge from has a currency field in it. When I look in the field it has the $0,000,000.00 format, however when I do the mailmerge it formats it to the text of 0000000 how can I s


send query data to word doc via mailmerge V's Bookmarks -
i have searched but cannot find the best method of exactly how to achieve (Access not VB6) from a custom menu, send data from a query to a word document with either mailmerge or bookmarks. how can i do this and wich is the best method?


word mailmerge from excel data -
is it possible to set which sheet for word to use for mailmerge data, i have tried a few things, but it always uses sheet1, though sometimes it tries to work with a range from another sheet it still uses the data from sheet1


Word Mailmerge problem (VBA): new name for merged document -
How to give a merged document another name than the one that's been attributed automatically by Word (Office 2000)? According to me the Mailmerge Object doesn't possess a name property for the merged document. Is it possible to use code to determine the name Word attributed to the me


MailMerge Loses Table Formatting -
I have a draft ammount in my Microsoft Access database tha automatically calculates currencies for me(the table is formatted for currencies). So the table stores numbers like this: 1921.2 as $1,921.20... But when i press the mailmerge key on my word document, the draft ammount look


[WORD] Execute MailMerge in VB6 -
I am trying to use VB6 to open a MailMerge document. This Word document is connected to a Text file as datasource. When I try to open c:\source\letter1.doc, a message box will pop up: Quote: Opening this document will run the following SQL command: SELECT *


MailMerge Operations (Word.Application) -
Hi all! I have a problem whith a MailMerge Operation in Word, I have made all the mail merge things from VB whith a txt file buld from VB but allways the word shows the window where I must select the field separator and the rec Separator. How can I say this separators with parame


Access Mailmerge Automation -
Can anyone tell me how I can perform a mailmerge by opening up word from access and performing a mailmerge automatically without opening access again as the datasource? I've copied the script below, if anyone has any suggestions please help!!! Dim objWord As Word.document Dim mywd


mailmege error 5852 with XP-works fine in 2000 -
I have a VB app that automates Word mailmerge It use an Access database for the input to the maimerge. The application works fine in 2000 and doesn't work in XP. I get the error 5852 requested object is not available. I get this message when it tries to execute the following line of


Resolved: Package and Deployment Problems -
I have used the PDW before with no problems. However, this app I'm trying to package has some text files necessary for storing data and retrieving. When I manually add these files in the wizard they do not appear in the setup.lst and are not installed either (they don't even get put


MailMerge and saving file -
Looking for a way in VB to do the following.. Parts 1 and 2 I have done.. Part 1 ... Select a datasource and fill with data Part 2 ... Select a .dot file and execute the mailmerge file using the datasource created and saved in part 1 PART 3 .. This I need... How can I save the newl


remember to use -
Can evryone who has a post that has been resolved, please put [Resolved] in the title of their posts. It gets annoying to keep having to come back to the same problems when an answer has already been provided. Thank you


opening a Word mailmerge datasource -
I have created a mail merge datasource and open it via the Word object library in my app. If this is done with a PC with office 2000 on, then everthing is Ok. If it is a PC with office97 on, then I get an error opening data source. If I do this manually through word, I get the same pro


visual basic problems please help! -
the person before me had an old access database which someone converted to access 2000 this access database merges with word and prints payoff docs - we are getting all kind of problems especially lock problems - error 2486 Run-time error '2486';" ("You can't carry out th


Automating Mail Merge with Word through VB 6 -
I have several Word 2000 Mail Merge Templates that I need to automate through my VB 6 application.# The code I'm using at the moment is: Dim wrdApp As Word.Application, wrdDoc As Word.Document, wrdMerge As Word.MailMerge ' create an instance of microsoft word.


Help with Word and Visual Basic -
Hi I am new to Visual Basic and here is the project I must compelte. We currently have a Word document (that we mailmerge a flat file too). This document contains information for new hires. The users have asked that we add a couple of dropdown list boxes to the word document for t


access, word and headaches... -
OK, long and comlicated.... basically I'm trying to mailmerge a current record to word. I have a query that finds the current record from the key on the form but when i try to mailmerge it word starts a new session of access and then, no surprise, the query prompts for the form fie


access database, word mail merge... need i say more =) -
OK, long and comlicated.... basically I'm trying to mailmerge a current record to word. I have a query that finds the current record from the key on the form but when i try to mailmerge it word starts a new session of access and then, no surprise, the query prompts for the form fie