Print Preview with Lotusscript

hi,

what i try to achieve is to have a print preview button in a form. Since the document that I want to see in the print preview window is a different form i first create a dummy document so that i get focus on it and then press programmatically the keyboard shortcuts to open the print preview dialog. but when the print preview window closes I want the dummydoc to dissappear/close (since this form is for printing only and should not be visible to the user).

But the code below closes the document before the keystrokes and print preview shows the initial form instead of the one i give to it.

Any ideas??

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document

Set dummydoc = db.CreateDocument

dummydoc.Form = “FORM2”

Call doc.CopyAllItems(dummydoc)

Set dummyuidoc = ws.EditDocument(False, dummydoc, , , True, True )

KeyPress VK_MENU, 0, 0, 0

KeyPress VK_MENU, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_F, 0, 0, 0

KeyPress VK_F, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_W, 0, 0, 0

KeyPress VK_W, 0, KEYEVENTF_KEYUP, 0

dummyuidoc.Close 'this runs before the keystrokes

Thank you in advance

Subject: Print Preview with Lotusscript

I am not sure if keypress ever worked, search this forum there is a document explaining how to do it calling the Windows functions.

Subject: RE: Print Preview with Lotusscript

thanks for your immediate answer.

This code does work, the keystrokes open the print preview window of lotus notes, except from the fact that the dummyuidoc.close statement executes before the keystrokes, instead of being executed after the keystrokes in order to close the uidoc.

I even introduced delay with Sleep 4 but still it produced the same results.