|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
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