• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

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
0
Sheils
Asked:
Sheils
  • 4
  • 2
1 Solution
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now