Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mailmerge: Word x Excel
Message
 
À
09/03/2006 11:16:43
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01102783
Message ID:
01103101
Vues:
17
Fernando,

I believe, your wsqlstatement statement needs the sheet name, not the file name. Try to change it to something similar to (with quotes and $ sign surrounding the sheet name!)
 wsqlstatement  = "SELECT * FROM `sheet1$`"
>Hi,
>
>I'm trying to perform a mailmerge using an Excel spreadsheet as the datasource.
>
>I prepared the Word 2003 documento (model) and the Excel 2003 (datasource) and by openning the Word document it merges with data contained in the spreadsheet,ok.
>
>Just before the mailmerge, Word promps with a message like (sorry it was in portuguese and I translated):
>
>"When this document be openned, the following SQL command will be executed: SELECT * FROM C:\SisCoopMinu\Modelos\Informe de Rendimentos Financeiros.Xls. Data from the data base will be inserted into the document. Do you like to continue?"
>
>I press "YES" and it performs the mailmerge all right.
>
>When I run the programa below, it just doesn't work, ginving an error message saying that Word couldn't open the data source.
>
>Any ideas of what the problem is?
>
>Thanks!
>
>Fernando
>
> SelModelosDir = "C:\SisCoopMinu\Modelos\"
>
> SelModelo     = SelModelosDir + "Informe de Rendimentos Financeiros.Doc"
> SelArqDados   = SelModelosDir + "Informe de Rendimentos Financeiros.Xls"
> SelMergeDoc   = SelModelosDir + "Relação de Informes.Doc"
>
> oWord = CreateObject ("Word.Application")
>
> oWord.Application.Visible     = .T.
> oWord.Application.WindowState =  1
>
> oDocument = oWord.Documents.Open (SelModelo, 0, 0, 0)
>
> wdOpenFormatAuto = 0
>
> With oWord
>
>      dsname         = SelArqDados
>      wformat        = wdOpenFormatAuto
>      wconfirmconv   = 0
>      wreadonly      = 0
>      wlinktosource  = 1
>      waddtofilelist = 0
>      wpassworddoc   = ""
>      wpasswordtemp  = ""
>      wrevert        = 0
>      wprotectdoc    = ""
>      wprotecttemp   = ""
>      wconn          = "DSN=Arquivos do Excel,DBQ=" + ;
>                        SelArqDados                 + ;
>                       ";DriverId=790;MaxBufferSize=2048;PageTimeout=5;"
>      wsqlstatement  = "SELECT * from " + SelArqDados
>      wsqlstatement1 = ""
>
>      .ActiveDocument.MailMerge.OpenDataSource (dsname        , ;
>                                                wformat       , ;
>                                                wconfirmconv  , ;
>                                                wreadonly     , ;
>                                                wlinktosource , ;
>                                                waddtofilelist, ;
>                                                wpassworddoc  , ;
>                                                wpasswordtemp , ;
>                                                wrevert       , ;
>                                                wprotectdoc   , ;
>                                                wprotecttemp  , ;
>                                                wconn         , ;
>                                                wsqlstatement , ;
>                                                wsqlstatement1)
>
>      .ActiveDocument.MailMerge.Destination = 0
>
>      .ActiveDocument.MailMerge.Execute
>
> EndWith
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform