Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mailmerge: Word x Excel
Message
From
11/03/2006 08:49:06
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01102783
Message ID:
01103375
Views:
13
Hi Yury, thanks for replying!

Unfortunatelly it didn't work.

If you'd like (and permit me) I could send you the set of files to reproduce the problem I'm facing (the Word document, the Excel spreadsheet and a complete screenshot sequence of the operation with error messages).

You wouldn't have any compromise if you agree to send the files, of course! Maybe that could help you to check if there are any details I'm missing.

As far as I could notice, this problem came along with Office 2003 (actually from Word 2002 on).

Regards,

Fernando

>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
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform