Hi,
Not sure if this forum is the correct place, please advise if there is a better forum.
I'm trying to print an envelope by automating MS Word. This works fine for me in Access VBA, but having problems with VBScript. Here is my code, modified to work in VBScript:
Code:
Dim wd, Doc
Set wd = CreateObject("Word.Application")
wd.Visible = False
Set Doc = wd.Documents.Add
Doc.Envelope.PrintOut , fullAddress, , , retAddress
Doc.Close False
Set Doc = Nothing
Set wd = Nothing
Note fullAddress and retAddress were set previously, and contain text and VbCrLf's.
The PrintOut method results in a type mismatch error.
The documentation says:
expression.PrintOut (ExtractAddress, Address, AutoText, OmitReturnAddress, ReturnAddress, ReturnAutoText, PrintBarCode, PrintFIMA, Size, Height, Width, FeedSource, AddressFromLeft, AddressFromTop, ReturnAddressFromLeft, ReturnAddressFromTop, DefaultFaceUp, DefaultOrientation, PrintEPostage, Vertical, RecipientNamefromLeft, RecipientNamefromTop, RecipientPostalfromLeft, RecipientPostalfromTop, SenderNamefromLeft, SenderNamefromTop, SenderPostalfromLeft, SenderPostalfromTop)
Note that Address is the second parameter and ReturnAddress is the 5th parameter. VBScript doesn't allow named parameters, so I had to use the commas to place the needed parameters in the correct position.
If I move the return address to the 4th position by removing a comma, it all works. I understand the return address won't print because I did not send it in the proper position. But why do I get a type mismatch with it in the right position?
Any ideas what is going wrong?