php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24962 Incompatible variant type in call to MailMerge.OpenDataSource
Submitted: 2003-08-06 03:53 UTC Modified: 2003-08-17 15:24 UTC
From: David dot Richards at Tools dot co dot uk Assigned:
Status: Wont fix Package: COM related
PHP Version: 4.3.3RC2 OS: Windows XP Pro SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: David dot Richards at Tools dot co dot uk
New email:
PHP Version: OS:

 

 [2003-08-06 03:53 UTC] David dot Richards at Tools dot co dot uk
Description:
------------
When trying to call the OpenDataSource method of the MailMerge object in Word(Office XP Pro SP2) the following error is displayed in the web browser:-

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

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

The call accepts the BSTR but trying to specify any of the optional variants produces the error(optional parameter are require or word prompts the user to specify the table to use).  




Reproduce code:
---------------
$empty = new VARIANT();
$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",$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empt
y,$empty,$empty,$empty,"SELECT * FROM test$");


Expected result:
----------------
1. Word opens.
2. Add new document.
3. Start mail merge using the sepcified data source

Actual result:
--------------
Word opens but the mail merge fails to open the data source, producing the error above.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-12 07:32 UTC] richard dot quadling at carval dot co dot uk
Me being picky.

From OLEView ...

        HRESULT OpenDataSource(
                        [in] BSTR Name, 
                        [in, optional] VARIANT* Format, 
                        [in, optional] VARIANT* ConfirmConversions, 
                        [in, optional] VARIANT* ReadOnly, 
                        [in, optional] VARIANT* LinkToSource, 
                        [in, optional] VARIANT* AddToRecentFiles, 
                        [in, optional] VARIANT* PasswordDocument, 
                        [in, optional] VARIANT* PasswordTemplate, 
                        [in, optional] VARIANT* Revert, 
                        [in, optional] VARIANT* WritePasswordDocument, 
                        [in, optional] VARIANT* WritePasswordTemplate, 
                        [in, optional] VARIANT* Connection, 
                        [in, optional] VARIANT* SQLStatement, 
                        [in, optional] VARIANT* SQLStatement1, 
                        [in, optional] VARIANT* OpenExclusive, 
                        [in, optional] VARIANT* SubType);

Your code ...

OpenDataSource("c:\\temp\\test.xls",$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,"SELECT * FROM test$");

You are missing the 3 $empty's.

Try ...

OpenDataSource("c:\\temp\\test.xls",$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,$empty,"SELECT * FROM test$",$empty,$empty,$empty);

Richard Quadling
 [2003-08-12 07:57 UTC] David dot Richards at Tools dot co dot uk
Hi,

Thanks for the reply.

I did try it with the extra $empty's, but with no success.

Unfortunately the call only works with the BSTR parameter. 

Thanks
Dave
 [2003-08-17 15:24 UTC] iliaa@php.net
The com extension has been completely rewritten in PHP5 and the PHP4 com extension is no longer being maintained. If you find bugs with the com extension in PHP5 please report them.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 19:01:26 2024 UTC