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

Auto Close after Macro in MS Word

How to make MS Word Automatically close after running the Macro I attached below?
Sub MailMerge()
'
' MailMerge Macro
' Macro recorded 2010/4/13 by Billy Ma
'
    ActivePrinter = "Oce (Engine)"
    With ActiveDocument.MailMerge
        .Destination = wdSendToPrinter
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=False
    End With
End Sub

Open in new window

0
mawingho
Asked:
mawingho
  • 2
  • 2
1 Solution
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Closing teh document is:

ActiveDocument.Close False

CLosing teh application is however another matter since it would be closing itself and that doesn't work ... though using a different file could .. i.e. creating the macro as a VBS to run from the command line.#

Chris
0
 
mawinghoAuthor Commented:
hmmm...it closed the document, but not the word application...
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
I did say ...

1. Closing teh document is: ActiveDocument.Close False
2. CLosing teh application is however another matter since it would be closing itself and that doesn't work.


Closing yourself is a no no and needs a workaround i.e. as in teh suggestion calling the activity from a diofferent application that opens word, opens the doc, runs the macro and then closes the document and the application.

Chris
0
 
mawinghoAuthor Commented:
yes I know, but i run this application every 30 seconds, I do not want to open another word and close the ms word application.
thanks for your solution, very helpful!!
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

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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