Jump to content

Word udf help


Recommended Posts

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
Link to comment
Share on other sites

  • 1 month later...

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

  • 7 months later...

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

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
 Share

  • Recently Browsing   0 members

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