Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / October 2004

Tip: Looking for answers? Try searching our database.

Envelopes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wilson Pye - 04 Oct 2004 22:31 GMT
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
Graham Mayor - 05 Oct 2004 06:40 GMT
This is merge to an envelope? In which case you could use a conditional
field to insert the line feed and the field:

{Mergefield street1}{IF {Mergefield street2} <> "" "
{Mergefield street2}"}
{Mergefield city}

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi,
>
[quoted text clipped - 62 lines]
>
> Wilson
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.