Ask a questionAsk a question
 

AnswerVisual Foxpro

Answers

  • Tuesday, November 03, 2009 9:39 AMCetinBasozMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    How to Create Mail Merge in Visual Foxpro 6.0 Where using Office 2007

    *!*	Author: Cetin Basoz
    *!*	MailMerge sample that works with newer versions too
    Wait Window Nowait "Creating Word Document.Please wait..."
    
    #Define wdOpenFormatAuto	0
    #Define wdSendToNewDocument	0
    #Define wdSendToPrinter	1
    #Define wdSendToEmail	2
    #Define wdSendToFax	3
    
    lcConnection = "Provider=VFPOLEDB;Data source="+_samples+'data\testdata.dbc'
    Strtofile('','myDummy.udl')
    m.lcSource = Fullpath('myDummy.udl')
    
    lcSQLStatement = "select e.First_Name,e.Last_Name,e.Notes from [Employee] e"
    
    *** 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
    
    oWordDocument=Createobject("word.application") && Create word object
    With oWordDocument
      .documents.Add
      With .ActiveDocument.Mailmerge
        .OpenDataSource(m.lcSource, wdOpenFormatAuto,.F.,,.T.,,,,,,,m.lcConnection, m.lcSQLStatement)
        .EditMainDocument	&& Activate the main document
    
    
        *!*	Add some merge fields and typ text programmatically
        .Fields.Add(.Application.Selection.Range, "Last_Name")
        .Application.Selection.TypeText(", ")
        .Fields.Add(.Application.Selection.Range, "First_Name")
        With .Application.Selection.Font
          .Italic = .F.
          .Name = 'Arial'
          .Size = 10
        Endwith
        .Application.Selection.TypeText(Chr(13)+"Here is your notes data :"+Chr(13)+Chr(13))
        With .Application.Selection.Font
          .Bold = .T.
          .Color = Rgb(0,0,255)
        Endwith
        .Fields.Add(.Application.Selection.Range, "Notes")
        With .Application.Selection.Font
          .Bold = .F.
          .Color = Rgb(0,0,0)
        ENDWITH
    *    .Destination = wdSendToNewDocument
    *    .Execute()
    
      Endwith
    
      .Visible = .T.   && Show word app
      .Activate
    Endwith
    **** Set the LocaleId to the previous value
    =Sys(3006,Val(nlLocaleId))
    

All Replies

  • Monday, November 02, 2009 4:48 PMCraig BerntsonMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I would start with doing a web search for the words "FoxPro Word MailMerge".
    Craig Berntson MCSD, Visual FoxPro MVP www.craigberntson.com
  • Tuesday, November 03, 2009 7:03 AMKalpesh Chhatrala Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    check Below link. it may be helpful you

    http://www.tek-tips.com/viewthread.cfm?qid=1500523&page=3


    http://www.tek-tips.com/faqs.cfm?fid=2410

    http://www.tek-tips.com/viewthread.cfm?qid=1500523&page=3

    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh's Blog
  • Tuesday, November 03, 2009 9:39 AMCetinBasozMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    How to Create Mail Merge in Visual Foxpro 6.0 Where using Office 2007

    *!*	Author: Cetin Basoz
    *!*	MailMerge sample that works with newer versions too
    Wait Window Nowait "Creating Word Document.Please wait..."
    
    #Define wdOpenFormatAuto	0
    #Define wdSendToNewDocument	0
    #Define wdSendToPrinter	1
    #Define wdSendToEmail	2
    #Define wdSendToFax	3
    
    lcConnection = "Provider=VFPOLEDB;Data source="+_samples+'data\testdata.dbc'
    Strtofile('','myDummy.udl')
    m.lcSource = Fullpath('myDummy.udl')
    
    lcSQLStatement = "select e.First_Name,e.Last_Name,e.Notes from [Employee] e"
    
    *** 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
    
    oWordDocument=Createobject("word.application") && Create word object
    With oWordDocument
      .documents.Add
      With .ActiveDocument.Mailmerge
        .OpenDataSource(m.lcSource, wdOpenFormatAuto,.F.,,.T.,,,,,,,m.lcConnection, m.lcSQLStatement)
        .EditMainDocument	&& Activate the main document
    
    
        *!*	Add some merge fields and typ text programmatically
        .Fields.Add(.Application.Selection.Range, "Last_Name")
        .Application.Selection.TypeText(", ")
        .Fields.Add(.Application.Selection.Range, "First_Name")
        With .Application.Selection.Font
          .Italic = .F.
          .Name = 'Arial'
          .Size = 10
        Endwith
        .Application.Selection.TypeText(Chr(13)+"Here is your notes data :"+Chr(13)+Chr(13))
        With .Application.Selection.Font
          .Bold = .T.
          .Color = Rgb(0,0,255)
        Endwith
        .Fields.Add(.Application.Selection.Range, "Notes")
        With .Application.Selection.Font
          .Bold = .F.
          .Color = Rgb(0,0,0)
        ENDWITH
    *    .Destination = wdSendToNewDocument
    *    .Execute()
    
      Endwith
    
      .Visible = .T.   && Show word app
      .Activate
    Endwith
    **** Set the LocaleId to the previous value
    =Sys(3006,Val(nlLocaleId))