Alaska Software Inc. - Merge database with Word document
Username: Password:
AuthorTopic: Merge database with Word document
Piotr DziurlaMerge database with Word document
on Sat, 30 Jun 2012 13:13:54 +0200
Hi,
1. I create a file with the data you wish to merge (a DBF  file)
2. Then I create a document with inserted fields.

In my Xbase program was:

oWord := CreateObject("Word.Application")

oWord:visible := .F.

cFileWord:= 'c:\test\test.doc'
cFileDBF := 'c:\test\test.dbf'
oMyDoc := oWord:documents:open( cFileWord )

oMyDoc := oWord:ActiveDocument
oMyDoc:MailMerge:OpenDataSource(cFileDBF, .F., .F., .T., .F. )

oMyDoc:MailMerge:Execute(.T.)


and on some computers  this work fine, but on other I have trouble:
Word not merge the data file, display an error "File c:\test\test.dbf not 
found"
(File exist!) or bring a window for choice a Database Driver.
Why?
Piotr
James LoughnerRe: Merge database with Word document
on Sun, 01 Jul 2012 20:03:57 -0400
Whats different between the machines?

On machines that fail can you do it by running word on those files?

Does the user have full access to the tiles on all the machines?

Jim


On 06/30/2012 07:13 AM, Piotr Dziurla wrote:
> Hi,
> 1. I create a file with the data you wish to merge (a DBF  file)
> 2. Then I create a document with inserted fields.
>
> In my Xbase program was:
>
> oWord := CreateObject("Word.Application")
>
> oWord:visible := .F.
>
> cFileWord:= 'c:\test\test.doc'
> cFileDBF := 'c:\test\test.dbf'
> oMyDoc := oWord:documents:open( cFileWord )
>
> oMyDoc := oWord:ActiveDocument
> oMyDoc:MailMerge:OpenDataSource(cFileDBF, .F., .F., .T., .F. )
>
> oMyDoc:MailMerge:Execute(.T.)
>
>
> and on some computers  this work fine, but on other I have trouble:
> Word not merge the data file, display an error "File c:\test\test.dbf not
> found"
> (File exist!) or bring a window for choice a Database Driver.
> Why?
> Piotr
>
>
>
Piotr DziurlaRe: Merge database with Word document
on Tue, 03 Jul 2012 09:59:35 +0200
Jim,
that happened on workstation with Vindows Vista with Word 2007.
When I create this document (with Word), database file was in folder
on network disk (H:\MyFolder). In program I use the same folder
and on this computer have an error (Database not found). I have
another test installation on my pendrive, in which in Word document
was database from E:\MyFolder. When I insert this pendrive in these
workstation, it was mapped as F:. I create a path to database with
function CurDrive() and CurDir() so I call a database as
"F:\MyFolder\test.dbf".
In this case (only on this workstation) WWord object is created and
displayed, but connection with database is not created and Word as me
about database connection driver.

Piotr


Uzytkownik <James Loughner> napisal w wiadomosci 
news:73b25a1c$6ffed514$2467@news.alaska-software.com...
> Whats different between the machines?
>
> On machines that fail can you do it by running word on those files?
>
> Does the user have full access to the tiles on all the machines?
>
> Jim
>
>
> On 06/30/2012 07:13 AM, Piotr Dziurla wrote:
>> Hi,
>> 1. I create a file with the data you wish to merge (a DBF  file)
>> 2. Then I create a document with inserted fields.
>>
>> In my Xbase program was:
>>
>> oWord := CreateObject("Word.Application")
>>
>> oWord:visible := .F.
>>
>> cFileWord:= 'c:\test\test.doc'
>> cFileDBF := 'c:\test\test.dbf'
>> oMyDoc := oWord:documents:open( cFileWord )
>>
>> oMyDoc := oWord:ActiveDocument
>> oMyDoc:MailMerge:OpenDataSource(cFileDBF, .F., .F., .T., .F. )
>>
>> oMyDoc:MailMerge:Execute(.T.)
>>
>>
>> and on some computers  this work fine, but on other I have trouble:
>> Word not merge the data file, display an error "File c:\test\test.dbf not
>> found"
>> (File exist!) or bring a window for choice a Database Driver.
>> Why?
>> Piotr
>>
>>
>>
>
>
AUGE_ OHRRe: Merge database with Word document
on Tue, 03 Jul 2012 21:08:31 +0200
hi,

>>> oMyDoc:MailMerge:OpenDataSource(cFileDBF, .F., .F., .T., .F. )

how do you "use" DBF ?
as i understand you have to make a Connection via ODBC so my Macro look like 
this

Sub Makro2()
'
' Makro2 Makro
'
'
    ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
    ActiveDocument.MailMerge.OpenDataSource Name:= _
        "C:\Dokumente und Einstellungen\A\Eigene Dateien\Eigene 
Datenquellen\DATA Customer.odc" _
        , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", 
_
        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, 
_
        Format:=wdOpenFormatAuto, Connection:= _
        "Provider=MSDASQL.1;Persist Security Info=True;Extended 
Properties=""DSN=dBASE-Dateien;DBQ=C:\ALASKA\XPPW32\SOURCE\SAMPLES\DATA;DefaultDir=C:\ALASKA\XPPW32\SOURCE\SAMPLES\DATA;DriverId=21;FIL=dBase 
III;MaxBufferSize=2048;PageTimeout=5;"";Initial Catalog=C:\A" _
        , SQLStatement:="SELECT * FROM `Customer`", SQLStatement1:="", 
SubType:= _
        wdMergeSubTypeOther
End Sub

as you can see the DBF Path is "fix". if you want to use other DBF you have 
to apply new Path

greetings by OHR
Jimmy