help with background running and quitting

E

electrixnow

I am writing a macro that will be envoked on the command line:

winword /mmerge /q C:\file.doc

The macro merges a datafile with file.doc and then prints the filled in
document.

I want it to run in the background without displaying the GUI. The /q
turns off the splash screen.
I think the following turns of the GUI.

Application.Visible = False

Does anyone know how to close without saving the document and exit
winword?

I have tried the following:

ActiveDocument.Close
Application.DisplayAlerts = False
Applicaton.Quit

help show the following syntax, but I don't know the format:

Application.Quit(SaveChanges, Format, RouteDocument)
Application._Quit

Any examples or help please.

Thanks,

Grant
 
D

Douglas J. Steele

Application.Quit SaveChanges:=wdDoNotSaveChanges

If you don't have a reference set to Word, try using

Application.Quit SaveChanges:=0
 
E

electrixnow

Thanks, that works!

If you know how to make word totally invisible when running let me
know.

with the /q and application.visible set to False, I still get a window
poping up for a few seconds. It's winword but you don't see any
buttons, bars, or doc file.

Thanks

Grant
 
D

Douglas J. Steele

Personally, I wouldn't use winword /mmerge /q C:\file.doc to launch it: I'd
use Automation for everything.
 
E

electrixnow

What do you mean, Automation for everything?
Can you show me an example?
And do you know why you see winword pop a window even if you set it to
non-visable and use the /q swith?


Thanks,

Grant
 
D

Douglas J. Steele

You're using Shell to open Word, and then you're trying to work with it.
Instead, use

Dim objWord As Object

Set objWord = GetObject("Word.Application")
objWord.Visible = False

and go from there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top