Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Ahsan Rana
  Where is Ahsan Rana?
 Lahore
 Pakistan
 Ahsan Rana
 Tags
Subject: RE: Office Automation
Thread ID: 209577 Message ID: 209698 # Views: 3 # Ratings: 0
Version: Visual FoxPro 7 Category: Forms
Date: Tuesday, December 30, 2008 2:28:03 PM         
   


I thought you would read the reply before replying back:(
1) You can use a template as commented in code
2) Remove the extra formatting part
3) Execute mailmerge with destination set to printer

Please read this time.

#Define wdSendToEmail  2
#Define wdSendToFax  3
#Define wdSendToNewDocument  0
#Define wdSendToPrinter  1

Select * From customer Into Cursor mergethese
MergeIt('mergethese')

Function MergeIt
  Lparameters  tcAlias, tcTemplateDoc
  Local nLocaleID,lcTemp,lcHeader
  Local loWord,llToPrinter,lcSourceDoc

  *** set the LOCALEID to English
  nlLocaleId=Sys(3004)  && Save local id
  =Sys(3006,1033)       && We will be sending instructions in English
  *** set the LOCALEID to English

  * Prepare source
  Select (m.tcAlias)
  lcTemp = Sys(2015)+'.tmp'
  Copy To (lcTemp) Type Delimited With "" With Tab
  Afields(laFields)
  lcHeader = ''
  For ix = 1 To Fcount()
    lcHeader = lcHeader + ;
      Iif(Empty(m.lcHeader),'',Chr(9)) + ;
      Field(m.ix)
  Endfor
  lcSourceDoc = Sys(5)+Curdir()+'MergeSource.txt'
  Strtofile(m.lcHeader+Chr(13)+Chr(10)+Filetostr(m.lcTemp),m.lcSourceDoc)
  Erase (m.lcTemp)

  loWord=Createobject("word.application")	&& Create word object
  With loWord
    .documents.Add(m.lcTemplateDoc)  && Open a template
    With .Activedocument.Mailmerge
      .OpenDataSource(m.lcSourceDoc) && Set file as data source for mailmerge

      If llToPrinter
        .Application.Options.PrintBackGround = .T.
        .Destination = wdSendToPrinter
      Else
        .Destination = wdSendToNewDocument
      Endif
      .Execute

    Endwith
    .Visible = .T.  && Show word app
    .Activate  && Make it the active foreground app
  Endwith

  **** Set the LocaleId to the previous value
  =Sys(3006,Val(nlLocaleId))


Cetin Basoz

ENTIRE THREAD

Office Automation Posted by Ahsan Rana @ 12/29/2008 5:43:40 PM
RE: Office Automation Posted by Anders Altberg @ 12/29/2008 5:57:50 PM
RE: Office Automation Posted by Ahsan Rana @ 12/29/2008 6:42:14 PM
RE: Office Automation Posted by Anders Altberg @ 12/30/2008 1:31:09 PM
RE: Office Automation Posted by Biju Thomas @ 12/30/2008 3:13:41 AM
RE: Office Automation Posted by Anders Altberg @ 12/30/2008 12:56:46 PM
RE: Office Automation Posted by Cetin Basoz @ 12/29/2008 7:09:42 PM
RE: Office Automation Posted by Ahsan Rana @ 12/30/2008 6:01:31 AM
RE: Office Automation Posted by Cetin Basoz @ 12/30/2008 2:28:03 PM
RE: Office Automation Posted by Yousfi Benameur @ 12/29/2008 10:36:49 PM
RE: Office Automation Posted by Biju Thomas @ 12/30/2008 3:23:16 AM
RE: Office Automation Posted by Yousfi Benameur @ 12/30/2008 2:04:47 PM
RE: Office Automation Posted by Ahsan Rana @ 12/30/2008 5:48:52 AM
RE: Office Automation Posted by Yousfi Benameur @ 12/30/2008 2:15:45 PM
RE: Office Automation Posted by Ahsan Rana @ 12/31/2008 5:55:57 AM
RE: Office Automation Posted by Anders Altberg @ 12/30/2008 5:06:44 PM
RE: Office Automation Posted by Ahsan Rana @ 12/31/2008 5:53:31 AM
RE: Office Automation Posted by Yousfi Benameur @ 12/30/2008 2:00:54 PM
RE: Office Automation Posted by Cetin Basoz @ 12/30/2008 3:52:57 PM
RE: Office Automation Posted by Yousfi Benameur @ 12/30/2008 6:30:56 PM
RE: Office Automation Posted by Ahsan Rana @ 1/1/2009 6:37:54 AM