ID: 24962
User updated by: David dot Richards at Tools dot co dot uk
Reported By: David dot Richards at Tools dot co dot uk
Status: Open
Bug Type: COM related
Operating System: Windows XP Pro SP1
PHP Version: 4.3.3RC2
New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2003-08-12 07:32:28] 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* PasswordDoent,
[in, optional] VARIANT* PasswordTemplate,
[in, optional] VARIANT* Revert,
[in, optional] VARIANT* WritePasswordDoent,

[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-06 03:53:09] 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->Doents->Add();
$word->ActiveDoent->MailMerge->MainDoentType = wdFormLetters;
$word->ActiveDoent->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 doent.
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.


------------------------------------------------------------------------


--
Edit this bug report at [url]http://bugs.php.net/?id=24962&edit=1[/url]