+ Reply to Thread
Results 1 to 9 of 9

From Excel macro, Open (but do not run) an existing Mail Merge Doc

  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    30

    From Excel macro, Open (but do not run) an existing Mail Merge Doc

    HI ever one. I have developed (with a lot of help from this forum ) at tool to process a PO download report, create summaries, archives, and source data for Mail Merges. I also have created the Mail Merge Word documents. The final step is to have the Excel Macro open, but not run the mail merge documents. (Ultimately I will wan to run, but until validated & users acclimated I just want to open for now) I am getting hung up with the Word Warning: "Opening this document will run the following SQL Command:... Do you wish to continue" The default is NO and I have scoured the internet without finding a solution that I can get to work.

    My Excel Macro updates the source: C:/Documents/My Data Sources/14 Day Mailing List.xlsx and the mail merge doc points to it.

    I need it to open the mail merge file: C:/Documents/3 Mail Merge/14 Day Mailing List.docx

    Can anyone help me resolve the Word warning to "Yes" and open the doc?

    Thank you!!!!

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    Hi,

    The following link address your specific problem with the "Opening this document will run the following SQL Command:" message.
    http://www.gmayor.com/word_vba_examples.htm

    Lewis

  3. #3
    Registered User
    Join Date
    06-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    Thanks for the reply & the link Lewis. I think I could probably fiddle with the code & through trial & error get it to run. Maybe I will even not mess up my computer I am concerned about playing with the Registry - especially as I'll be installing this macro on other people's machines.

    I was hoping there was code that could be written into the Excel macro that would just answer "Yes" to the SQL challenge.

    Can you help me with that?

    Thanks again!!!

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    I created a mail merge word document and a mail merge Excel data file on my Vista32 bit system using Excel 2003. When I open the Word document manually, I get the 'SQL' message.

    I ran an Excel macro to run the 'Mail Merge' and it was successful in that it DID NOT get the 'SQL' message. I am not confident that my solution will work on your computer. Color me skeptical. If this doesn't work for you, I still may have one or two more tricks up my sleeve, but it may take a few days.

    My files are attached (which include extras) that do the following (all independent of each other):
    a. Run the mail merge from Excel.
    b. Open a new instance of Word from Excel.
    c. Open a Word file (that has an AutoRun macro) from Excel with AutoRun enabled.
    d. Open a Word file (that has an AutoRun macro) from Excel with AutoRun disabled.

    Lewis

    Code for the mail merge follows:
    Please Login or Register  to view this content.
    To open a new instance of Word from Excel:
    Please Login or Register  to view this content.
    To open a Word document (with AutoRun enabled):
    Please Login or Register  to view this content.
    To disable AutoRun place the following line before the line that opens the Word document where 'WordApp' is the Word application object as defined in the previous example:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    Thanks Lewis. I think I'll be able to get this to work when I'm back in the office tomorrow. If not, I'll just have open the mail merge doc manually. Your efforts are greatly appreciated. Thanks again!

  6. #6
    Registered User
    Join Date
    06-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    HI Lewis. I've been going through the code you sent. You really did a lot work here.

    I have spent the last 5 hours trying to get the code to work for me. I have been using Excel for a very long time, but am not a programmer. I usually build (not write) macros by recording & patching things from the internet together.

    The code you created for me assumes that all files are in the same folder - not the case.
    The PO report where my macro resides is in the "PO" Folder, the macro creates the mail merge source data as Excel files and puts them in the "My Data Sources" folder. Finally, the Word Mail Merge docs are in the "3 Mail Merge" folder. This is outlined above as:
    Source data - C:/Documents/My Data Sources/14 Day Mailing List.xlsx
    mail merge file - C:/Documents/3 Mail Merge/14 Day Mailing List.docx

    My original code opened the Mail Merge "14 Day Mailing List.docx" but did not maintain the link to the source data.
    I have tried to convert your code from the same folder to the separate folders actually being used & have failed.
    Perhaps we can try one more time. Below is the code that opens the doc but not does not past the SQL challenge.
    Hopefully you can solve that using the actual file names & paths and get the mail merge to open. I am running Office 2013 on a Windows 8.1 machine.
    Code[
    Dim objWord As Object
    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    objWord.Documents.Open "C:\Documents\3 Mail Merge\3 Day Mailing.docx"]

    Thanks again for all your help!!!

  7. #7
    Registered User
    Join Date
    06-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    PS: I actually have two mail merge files my people will be working with - 14 Day Mailing List.docx & 3 Day Mailing.docx - does not matter which one you use to write your code. Sorry for any confusion... Thanks again!

  8. #8
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    My main concern is that my solution works on your version of Windows and your version of Excel. Please download my files, put them in the same folder, and see if my simple mail merge works without the nasty 'SQL' message.

    In the mean time, I'll start working based on your feedback. I apologize for not reading your original post better. I also feel bad that you spent so much time trying to modify the code.

    Lewis

  9. #9
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: From Excel macro, Open (but do not run) an existing Mail Merge Doc

    Try the attached file. It permanently saves the folder and name of the 'Word' file, and permanently saves the folder and name of the 'Excel' file.

    Lewis
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Open Word mail merge file from excel button
    By jtemp57 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2014, 08:18 PM
  2. Replies: 2
    Last Post: 07-12-2012, 08:11 PM
  3. Missing Something - Open Word Mail Merge from Excel but no data source
    By Oz Dude in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2012, 07:25 PM
  4. Open and send an existing mail via an Excel macro
    By koltregaskes in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2011, 08:42 AM
  5. [SOLVED] Open a mail merge from excel: common problem
    By lightspeed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2006, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1