-
Word and VB6 problems
Hi,
I am performing a mail merge in MS Word from VB6.
I give the user the option of previewing the print. This works good, except when the user closes the print preview they are left with the word document. I would like it if this was not the case, and when they closed the preview, they were just back to the application again.
Does anyone know how to achieve this?
Set oApp = CreateObject("Word.Application")
oApp.ActiveDocument.PrintPreview
Cheers,
Rayden
-
So you want to shut down Word?
objDoc.Close 'False
Set objDoc = Nothing
oApp.Application.Quit True
Set oApp = Nothing
-
I only want the print preview to be shown, when I close that, I want the application to close as well.
I guess I would need to trap the print preview close event in orcer to exit the app at the same time.
-
I found the below code. Can anyone tell me what this does, and does it do what I want i.e open word, display the print preview, then when the user closes the print preview, automatically close word also...
Code:
WordHwnd = FindWindowEx(0&, 0&, "OpusApp", vbNullString)
DocHwnd = FindWindowEx(WordHwnd, 0&, "_WwG", vbNullString)
.
.
.
doc.PrintPreview
msword.Visible = True
Do While Not ActiveDocument.Close
Loop
Do While DocHwnd <> 0
Ret = WaitForSingleObject(DocHwnd, INFINITE)
Loop
msword.Quit Savechanges:=wdDoNotSaveChanges
Set msword = Nothing