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