Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word with Variable DataSource
Message
 
To
21/03/2002 09:16:43
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00635395
Message ID:
00635454
Views:
18
>>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

Cetin,

Sorry to be a pain :) but if you create the template (which has been saved with a DataSource location) and then physically rename the directory the data file is in. Then Add from the template do you get the OpenSource Dialog?
Caroline
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform