473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Mail Merge from Access

I have the following code for mail merge..It seems to be working, but even though I have the sql in the sql statement, it is still popping up a few things, which I need to avoid..
The first one is Microsoft Word Document with Yes/No buttons:

Opening this document will run the following SQL Command:
Select * from '00005067'
Data from your database will be placed in the document. Do you want to continue?

The next one is a window with a list of tables from the database to select from, even though I am already defining the sql statement in the code below..

Is it possible to avoid these two prompts?
Any help from you will be greatly appreciated. Thank you for your help in advance.

Expand|Select|Wrap|Line Numbers
  1. Function MergeIt(fsHistoryId As String, fsTemplateId As String)
  2.    Dim objWord As Word.Document
  3.    Dim lsSql As String
  4.    lsSql = "Select * from " & [fsTemplateId] & " where historyId = " & fsHistoryId
  5.  
  6.    Set objWord = GetObject("H:\RDA\ITS\MailMerge\" & fsTemplateId & ".doc", "Word.Document")
  7.    ' Make Word visible.
  8.    objWord.Application.Visible = True
  9.    ' Set the mail merge data source as the Northwind database.
  10.    objWord.MailMerge.OpenDataSource _
  11.       Name:= CurrentDb.name, _
  12.       LinkToSource:=True, _
  13.       Connection:="TABLE " & [fsTemplateId], _
  14.       SQLStatement:=lsSql
  15.  
  16.  
  17.    ' Execute the mail merge.
  18.    objWord.MailMerge.Execute
  19. End Function
  20.  
  21.  
  22.  
Jan 11 '08 #1
5 1985
zaidlig
45
Did you try:

ObjWord.Application.DisplayAlerts = wdAlertsNone
Jan 11 '08 #2
I have tried that and it still doesnt seem to work..I even tried this..

DoCmd.SetWarnings False

It still doesnt work...
Jan 11 '08 #3
zaidlig
45
The Docmd would only set the warnings on the Access app. The warning you are seeing are from the Word app. That's why I included the ObjWord before the command.

Have your included the Word Reference in your Access code page? I think it may help to figure out what commands Word will respond to stop the warnings.
Jan 11 '08 #4
I noticed that it is triggering that message box right after executing this command...
Set objWord = GetObject("H:\RDA\ITS\MailMerge\" & fsTemplateId & ".doc", "Word.Document")

objWord.Application.DisplayAlerts = wdAlertsNone is after this line and hence ignoring that...
Jan 11 '08 #5
The Docmd would only set the warnings on the Access app. The warning you are seeing are from the Word app. That's why I included the ObjWord before the command.

Have your included the Word Reference in your Access code page? I think it may help to figure out what commands Word will respond to stop the warnings.
by the way, I am referencing the Microsoft word 11.0 object library
Jan 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
9
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
4
by: pmhaupt2 | last post by:
I developed an Access 2003 program that will allow the user to produce a group of Word letters that merge with data records from an Access database. I created a mail merge Word document and...
4
by: lesperancer | last post by:
I have 3 tables (office97) tblQuote quoteNbr tblDetails ( quote : 1 <-> M: quoteDetails) quoteNbr detailLine product value
5
by: johnvon | last post by:
I have a mail merge that runs flawlessly in Access 2000. In 2003 I keep getting dialog boxes that I can't figure out how to supress. Several of them are telling me that Admin (me!) has the database...
8
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to...
6
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all...
1
by: Esther Lane | last post by:
Hello! First off, many many thanks to Albert who wrote the Mail Merge code for MS Access I am using. It has been working beautifully for a few years. However, my client just (without notice!)...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.