Results 1 to 4 of 4

Thread: Word and VB6 problems

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2003
    Posts
    35

    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

  2. #2

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2003
    Posts
    35
    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2003
    Posts
    35
    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
    Last edited by raydenl; Apr 12th, 2004 at 08:20 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width