Jump to content
Sign in to follow this  
big_daddy

Microsoft Word Automation Library

Recommended Posts

@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


Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@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


Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

New update available! See update history in first post for changes.

As long as there are no bugs I will be submitting this version for inclusion in AutoIt's Standard UDFs.

Enjoy,

Bob

Share this post


Link to post
Share on other sites

The docs are there, I guess whoever added it forgot to commit it...

Jos thought he had.

All committed for the next Beta release ...

Thanks for all your hard work on this !!!

Jos

Share this post


Link to post
Share on other sites

Is it just the Word.au3 file from this topic that needs to be put in \Include? I can do that if it is.

I just PM'd you the version that should be included.

Thanks,

Bob

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...