Envelopes?

W

Wilson Pye

Hi,

I have a small problem with the code I am using to print an envelope.

The field 'street2' does not always contain information. The code I have is
producing a blank line when there is no second street address.

Can someone help me how to not create a blank line when there is no second
street address?

Here is my code:

* wordplayersenvelopenr.prg NO return address


#DEFINE CR CHR(13)
#DEFINE TAB CHR(9)
#DEFINE wdHeaderFooterPrimary 1
#DEFINE wdGray25 16
#DEFINE wdAlignParagraphCenter 1
#DEFINE wdAlignParagraphLeft 0
#DEFINE wdAlignParagraphRight 2
#DEFINE wdCollapseEnd 0
#DEFINE wdParagraph 4
#DEFINE wdWord 2
#DEFINE wdLineStyleDouble 7
#DEFINE wdUserTemplatesPath 2
#DEFINE wdGoToBookmark -1
#DEFINE wdUnderLineSingle 1
#DEFINE wdUnderLineDouble 3
#DEFINE wdUnderLineNone 0
#DEFINE wdCollapseStart 1
#DEFINE wdUserTemplatesPath 2
#DEFINE wdWindowStateMaximize 1
#DEFINE wdPrintCurrentPage 2
#DEFINE wdPrintAllDocument 0
#DEFINE wdDoNotSaveChanges 0
LOCAL cTemplatePath, oDocument, oMergedDocument, oWord, oRange,
oBorderRange, cText

* Open Word and create a new template document
oWord = CREATEOBJECT("Word.Application")
oWord.VISIBLE = .F.
oDocument = oWord.Documents.ADD(, .T.)

USE C:\tournakit\DATA\tempeventtu.DBF ALIAS tempeventtu IN 0
SELECT tempeventtu
oRange = oDocument.Range()
oRange.InsertAfter(tempeventtu.firstlast + CR)
oRange.InsertAfter(tempeventtu.company + CR)
oRange.InsertAfter(tempeventtu.street + CR)
oRange.InsertAfter(tempeventtu.street2 + CR)
oRange.InsertAfter(tempeventtu.citystzip)
oDocument.Bookmarks.ADD("EnvelopeAddress", oRange)
oDocument.Envelope.Printout(.T., , ,.T.,)
WITH oWord
DO WHILE .BackgroundPrintingStatus > 0
DOEVENTS()
ENDDO
ENDWITH
ClOSE TABLES
oWord.QUIT(wdDoNotSaveChanges)
RETURN


Thanks

Wilson
 
Top