Klexen Posted May 7, 2009 Share Posted May 7, 2009 (edited) I want to open an existing document, but to do that it seems I have to create a document first... ? $oWordApp = _WordCreate ("") $oDoc = _WordDocOpen ($oWordApp, "S:\IT\klexen\word.doc") This opens my document, and creates a "document1" How can I just open my existing document without creating a new one? Also, is there an easy way to "Ctrl+P + Enter" to print the page? Without using sendkeys? Like an _WordDocPrint ? Edited February 25, 2011 by Klexen Link to comment Share on other sites More sharing options...
Andy007 Posted July 4, 2009 Share Posted July 4, 2009 Hi Klexen,Have you tried:$oWordApp = _WordCreate ("S:\IT\Jason\word.doc")To Print...The code here will show you how to get the default windows printer.(I prefer Martin's GetDefaultPrinter1 function)$num_of_copies = 1 $selected_layout = 0 ; 0=Portrait 1=Landscape $default_printer = GetDefaultPrinter1() _WordDocPrint ($oDoc, 0, $num_of_copies, $selected_layout, 1, $default_printer)- more details in the Word help file. Regards,Andy (no, the other one) Link to comment Share on other sites More sharing options...
rotamo Posted February 24, 2010 Share Posted February 24, 2010 So I have a similar issue. I'm trying to open a .dot file as a .doc rather than allowing the user to overwrite the .dot. I have used both: $oWordApp = _WordCreate ("") $oDoc = _WordDocOpen ($oWordApp, "C:\Example\word.dot") and $oWordApp = _WordCreate ("C:\Example\word.dot") With the first example I am getting document2 as the dot file opened as a doc but I am also getting a blank document1 file. This is what I want aside from the blank file. When I use the other example, I do only get one file, but it is in .dot format where a user can overwrite the template. Definitely not the way to go. Any ideas? Link to comment Share on other sites More sharing options...
rotamo Posted February 24, 2010 Share Posted February 24, 2010 Solved the issue - not sure if it's the best way, but it works: $oWordApp = ObjCreate("Word.Application") _WordDocAdd($oWordApp,0,"C:\Example\word.dot") I then had to show the window with WinSetState() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now