Jump to content

Recommended Posts

Posted (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 by Klexen
  • 1 month later...
Posted

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)

  • 7 months later...
Posted

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?

Posted

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()

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...