mala direta com arquivo dbf

N

neia

Tenho um arquivo gerado pelo Visual FoxPro 6.0. Ao tentar criar uma mala
direta utilizando-o e confirmando a fonte de dados como "arquivos foxpro"
recebo as mensagens: "Unable do load ole32.dll" e "Falha de sqllochandle do
driver sql_handle-env".
Entrei no Painel de controle para tentar configurar o driver mas ele manda a
mesma mensagem "Unable do load ole32.dll" e não me deixa fazer nada.
 
P

Peter Jamieson

I am sorry I cannot write Portuguese, but...
....Can you open your FoxPro data source using Excel

Peter Jamieson
 
N

neia

Yes. I don´t have problem with excel.
However, I would like use FoxPro with Word, using mailmerge class.

"Peter Jamieson" escreveu:
 
P

Peter Jamieson

Sorry it has taken a while to get back to you on this.

I do not know what is going wrong where you are, but here the following
things worked, using Word 2003 and
a. the Visual FoxPro ODBC driver called "Microsoft Visual FoxPro Driver"
version 6.01.8629.01 (it also has a Portuguese name, "Driver para o
Microsoft Visual FoxPro")
b. the visual FoxPro OLEDB Provider version

Let's assume you have a folder called c:\fp containing a .dbc called db.dbc
and some .dbf files associated with the .dbc, including one called t.dbf

Then you should be able to connect in the following ways (at least):

Using ODBC to connect
-----------------------------------
Create an ODBC User or System DSN called fox.It doesn't matter whether you
set it up for a DBC or DBFs

For a DBC, use the following OpenDataSource call (sorry, you will need to
fix the line wrapping):

ActiveDocument.MailMerge.OpenDataSource _
Name:="", _
Connection:="DSN=fox;UID=;PWD=;SourceDB=C:\fp;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;",
_
SQLStatement:="SELECT * FROM `t`", _
SubType:=wdMergeSubTypeWord2000

For a DBF, use the following OpenDataSource call:

ActiveDocument.MailMerge.OpenDataSource _
Name:="", _
Connection:="DSN=fox;UID=;PWD=;SourceDB=C:\fp\db.dbc;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;",
_
SQLStatement:="SELECT * FROM `t`", _
SubType:=wdMergeSubTypeWord2000

Using OLEDB to connect
--------------------------

I am fairly sure that you cannot specify the .dbc or .dbf in the Name
parameter. I think you have to have a .udl or .odc file. These are just
plain text files that are supposed to provide connection details. However,
as far as I know either type of file can be an empty text file that you can
create in Notepad. Let's suppose you have such a file called c:\fp\fox.udl

Then try:

ActiveDocument.MailMerge.OpenDataSource _
Name:="c:\fp\fox.udl", _
Connection:="Provider=VFPOLEDB.1;Data Source=c:\fp\db.dbc;Mode=Share
Deny None;User ID="""";Password="""";", _
SQLStatement:="SELECT * FROM `t`"

or:

ActiveDocument.MailMerge.OpenDataSource _
Name:="c:\fp\fox.udl", _
Connection:="Provider=VFPOLEDB.1;Data Source=c:\fp;Mode=Share Deny
None;User ID="""";Password="""";", _
SQLStatement:="SELECT * FROM `t`"


If you want the user to be able to select the dbf, given a folder or dbc, I
suspect it is possible using a .odc, but ask again. (I will not be back for
a few days).

Peter Jamieson

To connect to a dbf, try
 
Top