Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2014, 08:24 AM
tariqaleed2 tariqaleed2 is offline After the Mail Merge not show dialog box Windows 7 32bit After the Mail Merge not show dialog box Office 2010 32bit
Novice
After the Mail Merge not show dialog box
 
Join Date: Jul 2014
Posts: 14
tariqaleed2 is on a distinguished road
Default After the Mail Merge not show dialog box

This is merge Mail code FROM MS ACCESS IT Works fine, but in the end show dialog box SAVE AS . Is it possible to help FOR not show dialog box , but save AS the file directly IN "C:\Users\LABTOP2\Desktop\end_of_ the_merger.docx"


not use the sendkeys




Greetings to all
Attachment work files
Code:
Private Sub COMM1_Click() 
    Dim objWord As Word.Application 
    Dim Doc As Word.Document 
    Dim sDBPath As String 
    Set objWord = CreateObject("Word.Application") 
    objWord.Visible = False 'True
    Set Doc = objWord.Documents.Open(Application.CurrentProject. Path & "\WORD" & ".DOCX") 
    With Doc.MailMerge 
        .MainDocumentType = wdFormLetters 
        sDBPath = Application.CurrentProject.Path & "\DATA1" & ".XLS" 
        .OpenDataSource Name:=sDBPath, _ 
        SQLStatement:="SELECT * FROM `wordqur1$`" 
    End With 
    With Doc 
        .MailMerge.Destination = wdSendToNewDocument 
        .MailMerge.Execute Pause:=False 
    End With 
    Doc.Saved = True 
    objWord.Quit 
    Set Doc = Nothing 
    Set objWord = Nothing 
End Sub
Attached Files
File Type: zip saveas.zip (45.5 KB, 10 views)

Last edited by macropod; 08-23-2014 at 03:00 AM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 08-22-2014, 03:54 PM
macropod's Avatar
macropod macropod is offline After the Mail Merge not show dialog box Windows 7 64bit After the Mail Merge not show dialog box Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There are code examples of how to do that near the bottom of this thread: https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-23-2014, 01:50 AM
tariqaleed2 tariqaleed2 is offline After the Mail Merge not show dialog box Windows 7 32bit After the Mail Merge not show dialog box Office 2010 32bit
Novice
After the Mail Merge not show dialog box
 
Join Date: Jul 2014
Posts: 14
tariqaleed2 is on a distinguished road
Default

Thank you very much macropod YOU help me a lot


The best way I found , is forcing the user to closing ALL WORD Documents before making action .
If there is another way, TO NOT be THE user forcing the closing ALL WORD Documents TO BE better else the problem was solved .




I repeat my thanks to you and TO the members
Greetings to all
Code:
Private Sub COMM1_Click() 
    Dim objWord As Word.Application 
    Dim doc, Target As Word.Document 
    Dim sDBPath As String 
    On Error Resume Next 
    Set objWord = GetObject(, "Word.Application") 
    On Error Goto 0 
    If Not objWord Is Nothing Then 
        MsgBox "one or more Word file is open ... Please closing the all Word documents before executing this action" 
        Exit Sub 
    End If 
    Set objWord = CreateObject("Word.Application") 
    objWord.Visible = False 'True
    Set doc = objWord.Documents.Open(Application.CurrentProject. Path & "\WORD" & ".DOCX") 
    With doc.MailMerge 
        .MainDocumentType = wdFormLetters 
        sDBPath = Application.CurrentProject.Path & "\DATA1" & ".XLS" 
        .OpenDataSource Name:=sDBPath, _ 
        SQLStatement:="SELECT * FROM `wordqur1$`" 
    End With 
    With doc 
        .MailMerge.Destination = wdSendToNewDocument 
        .MailMerge.Execute Pause:=False 
        With objWord.ActiveDocument 
            .SaveAs FileName:="C:\Users\TARIQ-LABTOP2\Desktop\rrrrrrrrrrrr.docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False 
             ' and/or:
            .Close SaveChanges:=False 
        End With 
    End With 
    doc.Saved = True 
    objWord.Quit 
    Set doc = Nothing 
    Set objWord = Nothing 
    MsgBox "Successfully complete a mail merge" 
End Sub

Last edited by macropod; 08-23-2014 at 03:04 AM. Reason: Added code tags & formatting
Reply With Quote
  #4  
Old 08-23-2014, 03:15 AM
macropod's Avatar
macropod macropod is offline After the Mail Merge not show dialog box Windows 7 64bit After the Mail Merge not show dialog box Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by tariqaleed2 View Post
The best way I found , is forcing the user to closing ALL WORD Documents before making action .
If there is another way, TO NOT be THE user forcing the closing ALL WORD Documents TO BE better else the problem was solved .
You need to learn how to automate Word correctly, so that you can create a new Word session or, perhaps, automate an existing Word session. If you do the former, you don't have to worry about whether Word is already running or whether the user has any documents open. If you do the latter, you need to ensure your code is properly written so that existing documents don't need to be closed.

For an example of the former, see:
https://www.msofficeforums.com/word-...variables.html
For an example of the latter, see:
https://www.msofficeforums.com/word-...e-ms-word.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.Dialogs - Show mail merge 'Select Recipients" dialogs Cosmo Word VBA 0 10-08-2013 07:58 AM
After the Mail Merge not show dialog box How to Use Mail Merge with conditions to show some features raiya Mail Merge 11 10-16-2012 11:04 PM
After the Mail Merge not show dialog box Mail Merge Fields Show Up As Track Changes When its Turned Off zoysiaspp Mail Merge 1 09-28-2012 08:23 PM
After the Mail Merge not show dialog box show dialog box rutica Mail Merge 1 06-02-2009 10:25 AM
opening mail attachment dialog box jeffcravener Outlook 0 06-28-2006 07:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:02 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft