Error when mail merging using Albert kallal's code while a word document is open

Hi

I have been using Albert Kallal mail merge code for a while without any problem. However, I have recently found a problem that I hope you expert can help solve.

When you try to fun the code to conduct a mail merge while a word document that was not opened by the code in access is already opened you get message saying:

This document will run the following SQL command:

Select * from C:\docume~1\................\temp\merge.888.

Data from your database will be placed in the document. Do you want to continue.


Clicking yes proceeds with the mail merge. Is there a way to make the code proceed without the message even when there is another open word document.

Albert Kallal db is in the attached zip folder
WordMerge2008.zip
LVL 16
SheilsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SheilsAuthor Commented:
I believe that I've found a fix. When I change the following:

On Error GoTo CreateWordApp
   
   If bolPrint = True Then
      ' we printing a document, so lets launch a seperate copy of word
      ' as not interfere with the the user's current open copy of word
     
      Set wordApp = GetObject("Word.Application")
   Else
      Set wordApp = GetObject(, "Word.Application")
   End IfOn Error GoTo CreateWordApp
   

TO

   If bolPrint = True Then
      ' we printing a document, so lets launch a seperate copy of word
      ' as not interfere with the the user's current open copy of word
     
      Set wordApp = GetObject("Word.Application")
   Else
      Set wordApp = GetObject("Word.Application") 'delete the comma before "Word.Application"
   End If

The word document opens without the message.

Please advice if such change will create other forseeable errors



0
GrahamSkanRetiredCommented:
I dont understand the code that you have posted, or the fix.

You do the same thing in the True and the False (Else) parts of the If block.


Also the message that you report is not an error, but is a security warning. This Microsoft article tells you how to modify the registry to remove the message.

http://support.microsoft.com/kb/825765
0
SheilsAuthor Commented:
Graham

In the original code there was a comma in from of "word.application"  in the Else part of the If block. The idea was that if a word document was already opened the code will open the new document in the same instance as the opened document. By removing the comma the new document opens in a new window no matter what. In effect I could just remove the If block and replace it by

 Set wordApp = GetObject("Word.Application")


To use the work around in the link you provided above, I'd have to change the register of every computer that have to us this database since it is on a network. So that's not practical.
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

GrahamSkanRetiredCommented:
Interesting. On my system it raises a run time error (800401e4)-  Automation error - Invalid syntax.
0
GrahamSkanRetiredCommented:
Ah. I see, I think.

You don't see the error because your line:
On Error GoTo CreateWordApp

will cause it to jump to the that lable wheere you presumable have a line such as

Set WordApp = CreatObject("Word.Application")

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamSkanRetiredCommented:
Yes, I've just checked the code in the database that you posted.

Actually, I don't think that would get round the security message. There is as OpenDatasourc line in the code, so perhaps the perhaps the document is not a mail merge document when it is opened, but the code turns it into one.



0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.