Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word with Variable DataSource
Message
De
21/03/2002 09:16:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00635395
Message ID:
00635450
Vues:
17
This message has been marked as the solution to the initial question of the thread.
>>>>>Hi everyone,
>>>>>
>>>>>Can someone please tell me how I can set up a Word MailMerge so that the Main Document doesn't hold the path to the DataSource?
>>>>>
>>>>>Thanks in anticipation.
>>>>
>>>>Caroline,
>>>>Create your template w/o a datasource. ie: Start for a mail merge and do not get data (step 2). Edit main document by inserting field (mergefield). Save as template.
>>>>Cetin
>>>
>>>Cetin,
>>>
>>>What if the user is in charge of creating the MailMerge Main documents now do you then change/stop the datasource path being saved?
>>>
>>>Thanks for all your help.
>>
>>Assuming merge fields exists in both paths I wouldn't bother. Just opendatasource of my choice (as in code I sent yesterday).
>>Cetin
>
>Cetin,
>
>I've been trying this but I keep getting the OpenDataSource Dialog coming up when I open the document. This requires use action so I can't set the source in the code as it never get to that line. Any suggestions now to stop the dialog coming up?

Caroline,
I do like this and get no dialog :
*Create and save the template routine
#define wdFormatTemplate  1
lcMYDBC = 'c:\myPath1\myDbc.dbc'
cSQLStatement1 = "SELECT * FROM employee"
cSQLStatement2 = ""

oWordDocument=createobject("word.application")	&& Create word object
With oWordDocument
  .Documents.Add && Use a predefined template
  .ActiveDocument.SaveAs(sys(5)+curdir()+'mytemplate.dot', wdFormatTemplate)
  With .ActiveDocument.MailMerge
    .OpenDataSource(,,,.T.,,,,,,,, ;
      "DSN=Visual FoxPro Database;SourceDB="+lcMYDBC+;
      ";SourceType=DBC;Exclusive=No;",;
      cSQLStatement1, cSQLStatement2) && Open data source - Link to source
    .EditMainDocument && Activate the main document
  Endwith
  .Visible = .t.
Endwith

* User modified and saved the template
* Merge routine
lparameters tcMyDBC && Might be from a different path
#Define wdSendToNewDocument  0
cSQLStatement1 = "SELECT * FROM employee where title like [Sales%]"
cSQLStatement2 = ""

oWordDocument=createobject("word.application")	&& Create word object
With oWordDocument
  .Documents.Add(sys(5)+curdir()+'mytemplate.dot') && Use a predefined template
  With .ActiveDocument.MailMerge
    .OpenDataSource(,,,.T.,,,,,,,, ;
      "DSN=Visual FoxPro Database;SourceDB="+tcMyDBC+;
      ";SourceType=DBC;Exclusive=No;",;
      cSQLStatement1, cSQLStatement2) && Open data source - Link to source
    .Destination = wdSendToNewDocument
    .Execute
  Endwith
  .Visible = .t.
Endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform