Hi,

I have a MySQL database which contains customer data. I have written a PHP
script to create a CSV file and then import the data into Microsoft excel
using COM, which has been saved into C:\TEMP\test.xls. I am now trying to
start a mail merge in word with the following code:-

com_load_typelib('Word.Application');

$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Visible = 1;
$word->Documents->Add();
$word->ActiveDocument->MailMerge->MainDocumentType = wdFormLetters;
$word->ActiveDocument->MailMerge->OpenDataSource _("c:\\temp\\test.xls");

I only want to setup the mail merge up to the point where the user can start
selecting fields.

The problem is that after word opens it prompts me to select a table.
According to the Microsoft documentation this is because the SQLStatement
parameter has not been specified in the call to OpenDataSource.

I have created a empty variant data type as follows:-

$empty = new VARIANT();

and used it in the new call where
OpenDataSource
("c:\\temp\\test.xls",$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empt
y,$empty,$empty,$empty,"SELECT * FROM test$",$empty,$empty,$empty);

When I run the script I get the following error:

Warning: (null)(): Invoke() failed: Type mismatch. Argument: 17 in
c:\program files\apache group\apache\htdocs\test6.php on line 93

 I didn't think I had specified 17 arguments.

I have checked want data types OpenDataSource is expecting and according to
OLE/COM view it is expecting a BSTR followed by 15 optional variants.

I apologise if this seems like a stupid question but I've only been
programming in php for a couple of months.  Any advice would be appreciated.

Thanks
Dave



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to