#1
|
|||
|
|||
Open MailMerge Documents and Ignore SQL Security Message
Hi,
I have 500 templates all linked to different databases for Mail merging. Last week, our DNS servers changed name so when we open these templates, it's a mess! I have a macro that will open each template and reassigned the proper MailMerge DataSource and SQL Statement. My problem is when the macro opens the documents, there is the SQL Security message that appears and now that I am working in VDI, I am no longer allowed to toggle the Security in the Registry Editor and the administrator won't allow me. Is there a code to add to the macro to ignore the SQL Security message when it opens each document? Thank you for your help! Souriane |
#2
|
||||
|
||||
This works in Excel - does it work with Word too?
Application.DisplayAlerts = False
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Good idea Guessed, but it doesn't work.
|
#4
|
||||
|
||||
Perhaps you might try this suggestion from the Microsoft KB
You receive the "Opening this will run the following SQL command" message when you open a Word mail merge main document that is linked to a data source It appears it would be a bad idea from a security viewpoint to leave this fix in place but it should let you apply a fix to the files. Another alternative is to burrow into the zip version of the xml files to find the old path and replace it with the new. This would avoid the need to open the file with Word until you have reset the path.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Well, this is usually THE best idea, but as I indicated in my initial message, I no longer have access to the Registry Editor. This is why I am trying to find a workaround...
|
#6
|
||||
|
||||
While it may not endear you to your IT support, you don't actually need to edit the registry directly to toggle the setting - you can do it with a macro. See the last macro at Word VBA examples.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
Thanks Mr. Mayor. I've already been using your great macro for years! Unfortunately, it is not only that I can't open the Registry Editor anymore, it's also that I can't edit any key registry at all with VBA.
I tried to see if I could use SendKeys to respond to the window but wasn't able to make it happen. In fact, what I want is to unlink the document with the database upon opening. Any suggestion? I tried myDoc.MailMerge.MainDocumentType = WdMailMergeMainDocType.wdNotAMergeDocument but it won't work as the document must be open to work and as long as the SQL Security message shows, well, it is not open yet.. |
#8
|
||||
|
||||
I did some testing and this works for me in Word. I can also use False instead of wdAlertsNone. I have no idea on why that doesn't work for you.
Code:
Sub TestOpen() Application.DisplayAlerts = wdAlertsNone Documents.Open FileName:="C:\aaa\MailMergeTest.doc" Application.DisplayAlerts = wdAlertsAll End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#9
|
||||
|
||||
Quote:
As demonstrated there, you will need to include the SQL statement in the VBA code. This applies to any code that disables the SQL message, not just to the code in the article.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hide Security Message and Print | rosscortb | Word VBA | 1 | 05-11-2017 03:39 AM |
When loading existing documents (*.docx) they load with Security Warning - Macros have been disabled | Franci | Word | 3 | 05-20-2016 04:33 AM |
Mailmerge Individual Documents | DaddyMac | Mail Merge | 4 | 06-06-2013 09:22 PM |
Excel 2007 security alert - data connection message every time? | michael.monaco | Excel | 0 | 12-20-2012 07:47 AM |
Open Word = security warning, changes hard drive | sleepymia | Word | 1 | 05-28-2012 05:49 PM |