Jump to content

Microsoft Word Automation Library


big_daddy
 Share

Recommended Posts

  • 2 weeks later...
  • Replies 115
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@BigDaddy

I have a problem in your script on line 246 when using the Word UDF together with the Excel UDF.

The problem seems to be the Error handler that is conflicting.

I added a an COM error handler in the script for Excel because the UDF does not have one in it yet.

But than running the 2 UDF in 1 script it gives an error in your UDF line 246.

You can run my example script tp see what is happening.

http://www.autoitscript.com/forum/index.php?showtopic=34865

regards

ptrex

Link to comment
Share on other sites

  • Moderators

@ptrex - I would suggest using the Word.au3 error handler for both UDFs. There are functions within Word.au3 that have to register its internal error handler. If it is unable to do so it will give an error, and the function will not continue. Being that you can only have one error handler active at the same time you can either do as suggested above or deregister and register each as they are needed.

Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators

@big_daddy

Works great !!

The only thing is, your Error handler writes to the stdout window.

While the usual COM Error give some popup messages.

Does your Error handler write to the CMD box if the scripts are compiled ?

Thanks

ptrex

Sorry for the late reply.

It wouldn't be proper for a UDF Library to have popup error messages. If you need this functionality then check the return values the same as you would for any other AutoIt Function.

Link to comment
Share on other sites

  • 2 months later...

@big_daddy

I don' t think you are correct here !!

Windows uses the principle of CASCADING setting.

This means if you launch a print command. Windows will look at the settings saved in the document.

If there are no settings in the doc. it will look at the printing preferrences saved in the users profile.

If there are no settings in the users prefs. than it will use the Default device settings.

Enjoy !!

ptrex

Link to comment
Share on other sites

  • Moderators

@ptrex - I know how it works. :)

I did find something that may work (not tested).

#include <Word.au3>

;WdPaperTray
Const $wdPrinterDefaultBin = 0
Const $wdPrinterUpperBin = 1
Const $wdPrinterOnlyBin = 1
Const $wdPrinterLowerBin = 2
Const $wdPrinterMiddleBin = 3
Const $wdPrinterManualFeed = 4
Const $wdPrinterEnvelopeFeed = 5
Const $wdPrinterManualEnvelopeFeed = 6
Const $wdPrinterAutomaticSheetFeed = 7
Const $wdPrinterTractorFeed = 8
Const $wdPrinterSmallFormatBin = 9
Const $wdPrinterLargeFormatBin = 10
Const $wdPrinterLargeCapacityBin = 11
Const $wdPrinterPaperCassette = 14
Const $wdPrinterFormSource = 15

$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print!"
$oWordApp.Options.DefaultTrayID = $wdPrinterManualFeed
_WordDocPrint($oDoc)
_WordQuit ($oWordApp)
Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

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...