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