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

mawinghoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.