Ask a Question related to PHP Development, Design and Development.
-
David Richards #1
COM mail merge problem!
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
David Richards Guest
-
Mail Merge??
Are there any Mail Merge capabilities using a PDF file as available in Microsoft word?? -
Mail Merge?
I have a client that I have designed a pdf newsletter for, and they would like to do a mail merge to send it out. They have a Filemaker database of... -
Mail Merge
Hi, I am adding an e-mail merge to my database. I used the wizard to set up the e-mail and link it to the data. However, some of my users are... -
Mail::Bulkmail - multipart breaks when doing mail merge
Hi, I've been using Mail::Bulkmail for a while now but never had to do both a mail merge and mutlipart togeather. I recently wrote a program that... -
Mail Merge (Urgent Help Need)
Hi everyone, I want to build a command button to merge a query to a word document. Could anyone tell me how to do it? I have a query(ComInfo)...



Reply With Quote

