MS Word Mailmerge Window Is Autominimizing

Jul 28, 2005

I just started having an issue with a mailmerge launching form in Access. A button I've set up, called "Order Form," uses the following code to launch Word, merge the data into the document, save the document, and close out the template. It's a large sample, and I think it may have come from this website at some point last year:

<---------START--------->

Private Sub OrderForm_Click()
'creates an SQL statement to be used in a query def
'On Error GoTo ErrorHandler

Dim val As String
Dim db As Database
Dim rec As DAO.Recordset
Dim strSQL As String
Dim strDocumentName As String 'name of the template document

Set db = CurrentDb
Set rec = db.OpenRecordset("SELECT Order_ID FROM tmpCurrentTGOrderID;")

While Not rec.EOF
val = rec("Order_ID")
rec.MoveNext
Wend

rec.Close

'Select all records from the record table were the table's Order_ID field matches
'that of the temporary table's.
'qry = "SELECT TG_Orders.Order_ID, TG_Orders.Order_Date, TG_Orders.Order_HonoredPerson, TG_Orders.Order_TreeGiver, TG_Orders.Order_PlantingState, TG_Orders.Order_Product, TG_Orders.Order_Type, TG_Orders.Order_Line1, TG_Orders.Order_Line2, TG_Orders.Order_Card, TG_Orders.Order_Occasion, TG_Orders.Order_First, TG_Orders.Order_Middle, TG_Orders.Order_Last, TG_Orders.Order_Have, TG_Orders.Order_Digits, TG_Orders.Order_CardType, TG_Orders.Order_Comments, TG_Orders.Order_Donate, TG_Customers.*, TG_Shipping.* FROM (TG_Customers INNER JOIN TG_Orders ON TG_Customers.Customer_ID = TG_Orders.Customer_ID) INNER JOIN TG_Shipping ON TG_Orders.Order_ID = TG_Shipping.Order_ID;"

strDocumentName = "TG_OrderForm.doc"

strSQL = "SELECT TG_Orders.Order_ID, TG_Orders.Order_Date, TG_Orders.Order_Confirmation, TG_Orders.Order_HonoredPerson, TG_Orders.Order_TreeGiver, TG_Orders.Order_PlantingState, TG_Orders.Order_Product, TG_Orders.Order_Type, TG_Orders.Order_Line1, TG_Orders.Order_Line2, TG_Orders.Order_Card, TG_Orders.Order_Occasion, TG_Orders.Order_First, TG_Orders.Order_Middle, TG_Orders.Order_Last, TG_Orders.Order_Have, TG_Orders.Order_Digits, TG_Orders.Order_CardType, TG_Orders.Order_Comments, TG_Orders.Order_Donate, TG_Customers.*, TG_Shipping.*, TG_Orders.Order_Cost, TG_Orders.Order_Remembrance "
strSQL = strSQL + "FROM (TG_Customers INNER JOIN TG_Orders ON TG_Customers.Customer_ID=TG_Orders.Customer_ID) INNER JOIN TG_Shipping ON TG_Orders.Order_ID=TG_Shipping.Order_ID "
strSQL = strSQL + "WHERE TG_Orders.Order_ID=" + val

Call SetQuery("TG_OrderFormQuery", strSQL)
Dim strNewName As String 'name to save merged document as
strNewName = "Order " & Format(CStr(Date), "MMM dd yyyy")
Call OpenMergedDoc(strDocumentName, strSQL, strNewName)

Exit Sub
ErrorHandler:
MsgBox "Error #" & Err.Number & " occurred. " & Err.Description, vbOKOnly, "Error"
Exit Sub

End Sub

Private Sub SetQuery(strQueryName As String, strSQL As String)
On Error GoTo ErrorHandler
'set the query from which the merge document will pull its info
Dim qdfNewQueryDef As QueryDef
Set qdfNewQueryDef = CurrentDb.QueryDefs(strQueryName)
qdfNewQueryDef.SQL = strSQL
qdfNewQueryDef.Close
RefreshDatabaseWindow
Exit Sub
ErrorHandler:
MsgBox "Error #" & Err.Number & " occurred. " & Err.Description, vbOKOnly, "Error"
Exit Sub
End Sub

Private Sub OpenMergedDoc(strDocName As String, strSQL As String, strReportType As String)
On Error GoTo WordError
'opens an instance of word, opens a merge template which has its data source
'already linked to a query in this database, merges the template,
'saves the merged file with a descriptive name, then closes the merge template

'Set the directory for any labels generated
Const strDir As String = "D:LOA-DataMerge Templates"
Dim objWord As New Word.Application
Dim objDoc As Word.Document
objWord.Application.Visible = True
Set objDoc = objWord.Documents.Open(strDir & strDocName)
' Make Word visible so that if any errors occur, you can close the instance of Word manually
objWord.Application.Visible = True
'merge to a new document
'if you are not sure of the SQLStatement to use in your OpenDataSource string, uncomment the following four lines to have the 'current SQLstatement print in the immediate window. You can then copy the returned string to your code
'Debug.Print objWord.Application.ActiveDocument.MailMerge.DataS ource.QueryString
'objWord.Quit
'Set objWord = Nothing
'Exit Sub

objDoc.MailMerge.OpenDataSource _
name:="D:LOA-DataLOAv817.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="QUERY TG_OrderFormQuery", _
SQLStatement:="SELECT * FROM `TG_OrderFormQuery`"
'notice that this is not the SQL statement that makes up the QueryDef of the query. It
'is the SQL statement that tells Word whether to use all the records returned by the
'Query. Notice also the funky single quotes – this is what DataSource.QueryString returned
'to me in the immediate window. I’ve also seen the query name written in 'brackets [ ],
'but have never tested this code with them.

objDoc.MailMerge.Destination = wdSendToNewDocument
objDoc.MailMerge.Execute
'save the merged document with a descriptive name
'you can delete this line if you want to leave the document with the default name “Labels 1” or “Letters 1”
objWord.Application.Documents(1).SaveAs (strDir & "" & strReportType & ".doc")
'close the merge template
objWord.Application.Documents(2).Close wdDoNotSaveChanges
'release the variables
Set objWord = Nothing
Set objDoc = Nothing

Exit Sub
WordError:
MsgBox "Err #" & Err.Number & " occurred." & Err.Description, vbOKOnly, "Word Error"
objWord.Quit
End Sub

<---------END--------->

Just today, this code started auto-minimizing the MS Word window, causing user error (after the documents been minimized, instead of clicking on the task bar, the user would click the button again, prompting that the document is already in use, would you like to save changes before closing the document, etc). Is there anything in this code that is telling Word to minimize? It's only happening on this one button, and there are 7 other mailmerge buttons on the same form, using the same code, that work fine.

Any help would be greatly appreciated,
Nate

View Replies


ADVERTISEMENT

Security Password - Access To Word Mailmerge

Apr 4, 2007

Dear Guru,

I have an issue which having read some previous threads may not be resolved simply. My database is password protected.

The password (presumably) is preventing the mailmerge from connecting the deata with the template. There is not even a password request shown. Is there any way that this can be overcome. There are a number of mailmerges but all are pulled from the same data query, can i unprotect this query only??

After convincing my boss that the dbase can easily run securely, your help will be very much appreciated.

Yours
Andrew - In sunny Hull, UK.

View 2 Replies View Related

Modules & VBA :: Access Mailmerge To Word Including Image

Nov 25, 2014

I have a database of film events, for which i have to do posters.

With the click of a button on a form, access opens word and puts all the fields in, including a field called [photo], which is the name of the image stored outside of the database.

Is there a way of getting that image into the word Document with all the other fields? Or have I just wasted an afternoon....

View 2 Replies View Related

Modules & VBA :: Automating Mailmerge From Access Form To Word Document

Aug 5, 2013

I am having the strangest results with my automated mailmerge. Basically it does work, but not all the time. The basic idea is to allow the user to dynamically create a query that produces a result list which fills a temporary table. The use then selects a prebuilt merge template and merge is executed against the temp table. The merge template are of the .doc type, but sme have been converted to .docx; the .doc files tend to work most often, but all of the will eventually get a Table is locked message... However if I run in test mode with code breaks and manually step through the process it always works... here is the heart of the code ...

Err_Pos = 10

Code:
DoCmd.SetWarnings False
' if tmp tbl left over from last run kill it
DoCmd.RunSQL "Drop table Word_Merge_Tmp_TBL"
Err_Pos = 12

[Code].....

There are many error cases in the error catch routine. That I have managed to make Access stop hanging when word has a problem or the table is locked. But I can't get the table to be free consistantly and why does it always work when I manually step through the code.

View 4 Replies View Related

Open Word Window On Access Form

Sep 6, 2005

Hello,
I am a researcher creating critical editions of ancient texts by collating readings from several manuscripts (i.e. different mss all contain minor differences). I create my edition in Word and use footnotes to record the variant readings. I also have a database - created from the word file - in which I can add context to each variant e.g. decisions, history etc. So I have a word file containing the text and its variants uniquely identified with a footnote reference and a database with one table and a record per variant and where the variant records are also unique and share the same number as the footnote. I would very much like to be able to open a window on my variant form which displays the word file at the correct variant (i.e. footnote reference) location. This will make it easier for me to record my assessments of the variant in the dbase while looking at where the variant occurs in the text. Obviously I don't need to see the footnote window as I have this info in the dbase.
I haven't got a clue how to do this and would appreciate any pointers.
Many thanks in advance,
Tim

View 1 Replies View Related

MailMerge Problems - Help Need

Jun 4, 2005

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:


Function MailMerge(strMMTemplate As String)
Dim objWord As Word.Application
Dim objDoc As Word.Document

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(fldMailmerge & strMMTemplate)

'Make Word visible.
objWord.Application.Visible = True
'Set the mail merge data source
objDoc.MailMerge.OpenDataSource Name:="C:cmoscmos.mdb", LinkToSource:=True, Connection:="TABLE tblMailMerge_Temp_Full", SQLStatement:="SELECT * FROM tblMailMerge_Temp_Full"
'Execute the mail merge.
objDoc.MailMerge.Execute
objDoc.Close

Set objWord = Nothing
Set objDoc = Nothing
End Function

I have searched high an low through the forum and web - but no luck.

Any ideas? I am running Access 2003.

Cheers

Will

View 4 Replies View Related

Access Mailmerge

Mar 2, 2006

Hi
Can anyone help?

I am trying to perform a mail merge from Access database table and using Word letter setup with all the necessary variables.
I am using VBA in access to perform this task.
All works ok to the point but the first snag I had when
the Access was not open in Read-Only mode and where
'OpenDataSource' statement was refusing to merge the database to the letter
I managed to overcome this by opening Access in Read-Only mode.

However I hit the second snag.

When running 'OpenDataSource' statement the pop up box comes with option to select a table I want to make connection too.

The table is listed in the within the parameters for the statement, so it does not make sense why is this question.


This is my code:-

Dim WordApp As Word.Application
Set WordApp = CreateObject("Word.Application")
MergePATH = Application.CurrentProject.Path & ""
With WordApp
.DisplayAlerts = wdAlertsNone
.Visible = False
.Documents.Open (MergePATH & "MTSheet3.DOC")
With WordApp.ActiveDocument.MailMerge

.OpenDataSource _
Name:=MergePATH & "io.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE tmpTable"

.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With
.ActiveDocument.SaveAs (MergePATH & "Dummy.doc")
.ActiveDocument.Saved = True
.ActiveDocument.Close
.Quit
End With

Set WordApp = Nothing



Can anyone explain what the problem ?

Thanks
The is holding up progress of a big project

View 3 Replies View Related

Mailmerge And Security

Dec 22, 2006

I am using Access 2003 and have secured my database, so that it now consists of an .mdb and an .mdw file. The .mdb is opened using the security settings in .mdw using a shortcut.

I want to set up a mail merge into Word 2003, but whenever I try selecting my database as the source of the data I want to merge, it won't let me log in.

Can anyone advise me how I can get this to work correctly?

Thanks,

Gary

View 3 Replies View Related

Handpick Records For Mailmerge

May 21, 2005

Hi,

the problem i have is this -

i have a stores database for all items in a warehouse. i need to be able to have a button on my form that sends the current record to a word template to be printed out on labels. i need to be able to specify the amount of labels for each record, and i need to be able to send multiple records to the same template. i have absolutely no idea how to do this.

ive got the template set up, but currently it is mailmerged the normal way, meaning it would just print every record in the DB on the labels. i was thinking of having some kind of check box in the DB so that the user can use the form to find all the records they want to print, check the box for each (and also enter a number for the amount of times they want that record printing on the sheet) and then have a button to send the final document to the printer. this brings up another issue - how do i empty the check box for every record each time the form is used so that all the previously printed records do not get reprinted?

If anyone has got any idea how to overcome any of these problems i would be extremely grateful.

Thanks

View 1 Replies View Related

Mailmerge Email With Attachment

May 21, 2012

In my database which is used by a charity I have a button which opens a mailmerge email document in MS Word using the following Visual Basic code -

FollowHyperlink "C:Our FoldersBWMCJuly Donors Email.docx", , True, True

This mailmerge document draws its personal information from a query in my database. And sends off personal emails to a number of donors.

I want to attach a personal document called 'Allocations.docx' which is also a mailmerge document drawing its personal information from the same query. How can I automate the attachment of this document to the email so that each donor gets their own email plus their own attachment?

Can something be added to the existing line of VB which will do what I want? If so, what do I need to add?

View 8 Replies View Related

Help: Pass Argument From Child Window To Parent Window?

Feb 15, 2005

Hi,

I have a parent window which upon clicking on a button will pop-up a child window containing a listbox. The listbox recordsource is a subset of the parent window. I want the user to select a record from the listbox which will load the selected record onto the parent window.

How does one pass argument back from child window to parent window?

From parent window to child window, I used
docmd.openform ,,,,,,[argument] and me.openargs in the child window

thanks in advance.

View 4 Replies View Related

Blank Address Lines In Mailmerge

Dec 27, 2007

I am trying to generate letters from ACC2003 db into Word2003. Reason for Word is so client can edit letters if required.
I have set up a maketable query to generate a temporary table in the Db and the mailmerge master document all formatted and pointed at the temporary table. I still need to get the automation running so that the letters merge and print on a command button.
My immediate issue is that the address lines are intentionally spread across 5 fields Addr1, Addr2, Addr3, Town, Postcode. Not all fields in every record are full, and with the query it would be impossible to eliminate fields on the chance they might be empty.
As a result my mailmerge has blank address lines which do not look professional.
Can anyone point me to how I might solve this given my proposed use - if it was a report then I have a little code module that neatly eliminates blank lines but I cannot see how I could integrate this into the mailmerge process.
Thanks for any help or pointers

View 2 Replies View Related

Modules & VBA :: Mailmerge Current Record And Save As New Document

May 25, 2014

I'm looking to add a button to my Customers form which will mailmerge the current record to a Word template and then save the Word doc as a new file (Ideally the customer's name).

I've looked at the Super Easy Mailmerge but I can't work out how to implement it without all of the variables (selecting documents etc.).

The files will all be saved to one location (C:CustomersExports) and this won't change.

This is also the location of the mailmerge template (C:CustomersExportsTemplate.docx)

View 9 Replies View Related

How To Match 4 Character Word Or Number Or Combination By Identical 4 Characters Word

Apr 11, 2013

How to match 4 character word or number or combination by identical 4 characters word or number or combination in one word have 10 or 15 characters.

I have to two separate tables (Table A and Table B). Table A has one column (Tag No) and Table B has about 15 columns with one column name Tag No as below

Table A

Table B

Tag No

Tag No

2009

ZZZ-2030-DC

2010

ZZZ-2010-M9P

[code]....

They're both in MS Access.I am trying to match 2 tables - columns (Tag No) with join query, but not success. I want to match 4 characters in Table-A with 4 similar characters in Table-B (Tag No) cell.What query is suitable to compare two tables.

View 8 Replies View Related

Word :: Sizing MS Word Table To Same Size As Recordset

Aug 14, 2014

My end goal is to populate a pre-existing table in an MS Word document with records from a query. The easiest way I've found (through scouring the internet) is to start with the code below (ran during OnClick() even in Access) to get the table the same size as the recordset:

Code:
Dim wDoc As Word.Document
Dim wTable As Word.Table
Dim wCell As Word.Cell
Set wDoc = appWord.Documents.Add(strDocLoc)
wDoc.Visible = True

[Code] ....

The code will shrink the table down just fine if the table has more rows than the recordset +1 (for header column). My hangup with this is the last line ("Selection.InsertRowsBelow 5") isn't executing; rows are not being added to the table. I get no errors -- it just does nothing. I set it as "Selection.InsertRowsBelow 5" arbitrarily just to see if it would even add rows, and sure enough it's not.

View 9 Replies View Related

Forms Are Opening In Same Window / How To Open Forms In Different Window

Oct 21, 2013

My application is developed in Access 2003 version. Recently we moved from Access 2003 to Access 2010. Now users are facing usability issues like - in Access 2003 all the forms are opening in different windows and they can move to forms easily. But in Access 2010 all the Forms are opening in same window, if they want to move to different forms then they need to close the current window or press ctrl+F6. How can I enable/open forms multiple window in Access 2010.

View 3 Replies View Related

Pop Up Window With F12 Key

Jul 20, 2007

For my Access DB, I have unselected the relevant options in Tools – Statup to hide the Objects window so that inexperienced users don’t corrupt the design of the forms, reports etc. However, I find that hitting F12 key brings a pop up window ‘Save Form (name of the form open appears here) To: ……….(blank text box). As ……(form or data access page options here)’ with OK and Cancel buttons. Hitting OK saves the form as it is and typing something after ‘To’ saves the form in that name. Though it doesn’t corrupt the DB in any way, I find this pop up window an irritant. Is there a way to stop this?

View 1 Replies View Related

Database Window Help

Mar 12, 2006

hi

ive been disabling the database window from the startup tab in MS access, just now when ive tryed to show it on startup it appears but its stuck in the top left hand corner and i cant move it! so i cant access the tables

help any1 pleassse

View 1 Replies View Related

Database Window

Mar 13, 2007

I've imported somebody's access db which hides the database window by default. When I click the db window button in the toolbar, the db window pops up high up and is somewhat hidden by the toolbar. I can't pull it back down as the top is hidden and when I try to move the toolbar,the db window simple moves up so I can't grab it and move it. Any suggestions?

scratch

View 1 Replies View Related

Stopping Pop Up Window Of F12 Key

Jul 20, 2007

In order to prevent inexperienced users corrupting the design of the Forms, Reports etc. of my Access DB, I have unselected the relevant options at Tools – Startup and it doesn’t display the Objects window. However, I find that when I press F12 key, a pop up window appears with ‘Save As’ ‘Save ‘frm……’ To: As …..’ with OK and Cancel buttons. Though a user can save the form with a different name and this does not interfere with the proper functioning of the DB, I find this an irritant pop up window. Is there a way to stop this pop up window?

View 2 Replies View Related

Can't Show Immediate Window

Sep 3, 2007

Hi, I have been using Access 2000 for quite a while now. I have been using the Immediate Window to call my code, but for some reason, this window won't display now, no matter what I do - I have repaired the installation and reinstalled it but to no avail

Is there any help out there for me?

View 5 Replies View Related

Database Window?

Apr 14, 2008

This may seem silly and I've seen no mention of it in this forum yet but the "Database Window" from previous versions of Access is now called the "Object Browser"? I had code to hide the database window on startup but can't seem to find a way to hide the object browser on startup. Any ideas? Also, is there another way to view my objects in ACC07 because this way is slowing me down tremendously! It's much more difficult to find the objects I'm trying to work on and visually see where I left off. Any help would greatly be appreciated! Thanks in advance.

View 6 Replies View Related

Please Help With Window Order

May 22, 2005

I have a button on a form that opens up a report. However, the report always opens in the background. How can it change so that once the button has been clicked on, the report comes to the foreground and the form in the background. Please see attached example. The button is called 'Label'.

Thanks in advance

Lee

View 3 Replies View Related

Minimize Window

Nov 10, 2005

Hi:

In MS Access:

In Forms section


DoCmd.OpenForm "Procedure", acNormal, , , acFormAdd, acDialog

I have one button for doing the above action, it works.

when the form come out, there is only close window (x), it doesn't have minimize window (_) option. How can I make minimize window button at the top right corner?

Thanks.

View 1 Replies View Related

After Displaying A Window...

Jul 6, 2005

Hello all you experts and thanks in advance for your help.

I want to issue a message box after a window (a form) is displayed. I have attached it (in VBA code) to the onOpen event but the message displays before the window is displayed. So I tried, OnCurrent, then onLoad, but in each case the event triggers the message box before the window is displayed.

Is there an event which triggers AFTER the display of the window. Note that I don't want the message box displayed several times so onGotFocus is out.

Many thanks in advance,

Phillip

View 2 Replies View Related

Parameter Window Help

Sep 8, 2005

Is there a way to have unlimited parameter boxes to pop up when a query is ran?

Thanks

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved