Solved

Error calling MSWord function from a Powerbuilder application

Posted on 2003-12-03
3
671 Views
Last Modified: 2013-12-26
We are calling a function Opendatasource() which belongs to MSWord from a PB app, by initiating a OLE object of MSWord. It was working fine with Word97 and Word2000 ver. Now with Word2002, it is not working. I have tried many things suggested by Microsoft website,other PB developers, search results from Internet and Knet tech.experts,over a period of 2 weeks but of no use. If someone can help me resolve this, I greatly appreciate that. Since one requires more detail before attempting a solution, Thanks and regards
0
Comment
Question by:Meena_kumari
3 Comments
 
LVL 33

Expert Comment

by:sajuks
Comment Utility
can u post a part of ur code so that it could be more understandable ?
0
 

Author Comment

by:Meena_kumari
Comment Utility
Process flow :
 
A Word document is stored in a Oracle database as blob.
It is retrieved during run time into a Blob variable and then assigned to a OLE control (OLE_1.Objectdata = Blob variable).
Then we declare a local variable of type "oleobject" and is initiated by OLE_1.object ( ole_object_variable = ole_1.object)
Now onwards we use the local "oleobject" variable to execute MSword methods(functions) like
ole_object_variable.mailmerge.opendatasource(...).
MS Excel spread sheet is used as data source.
We are NOT using "create" and "ConnectToObject" functions.
This setup was working fine with older versions of MSWord & MS Excel.
 
Opendatasource function description ...
 Ole_object.MailMerge.OpenDataSource(Name As String, [Format], [ConfirmConversions], [ReadOnly], [LinkToSource], [AddToRecentFiles], [PasswordDocument], [PasswordTemplate], [Revert], [WritePasswordDocument], [WritePasswordTemplate], [Connection], [SQLStatement], [SQLStatement1], [OpenExclusive], [SubType*])
Our current code...

iole_mergeto.MailMerge.OpenDataSource("c:\_junk.xls",la_zero,la_false,true,la_false,la_false,
la_nulstring,la_nulstring,la_false,la_nulstring,la_nulstring,"Entire Spreadsheet",la_nulstring,la_nulstring)

As per MS web site, to make this function work (in word2002) as before we need to pass a new parameter "SubType". They have given the value to be passed for that. But when I do, I get run time error "Illegal parameter passed..." .

Sometime it just says "Error calling External function..."

We are using PB 6.5, Win XP and Office XP.

I highly appreciate your any suggestions which helps me solve this critical, long standing issue.
0
 
LVL 2

Accepted Solution

by:
mdhampton earned 250 total points
Comment Utility
I noticed that the OpenDataSource documentation you show has 16 parameters, but your call has only 14. Are you missing SQLStatement1 and OpenExclusive?

Have you tried working with the code in a VB macro? Might help with debigging and such.

Acording to this article, it is optional:

From KB (KB324378) article "WD2002: Undocumented OpenDataSource Method Expression [SubType]"

Optional [SubType] Expression
The [SubType] parameter is an optional Variant that determines the method that Word uses to open a data source. It is one of the WdMergeSubType constraints. To have Word use the same connection methods as in earlier versions of Word, namely Dynamic Data Exchange (DDE) for Microsoft Access and Microsoft Excel data sources, use SubType:=wdMergeSubTypeWord2000.

WdMergeSubType constraints include:
wdMergeSubTypeAccess
wdMergeSubTypeOAL
wdMergeSubTypeOLEDBText
wdMergeSubTypeOLEDBWord
wdMergeSubTypeOther
wdMergeSubTypeOutlook
wdMergeSubTypeWord
wdMergeSubTypeWord2000
wdMergeSubTypeWorks

To find this information about the [SubType] expression, follow these steps:
In Word, point to Macro on the Tools menu, and then click Visual Basic Editor.
In the Visual Basic Editor, click Object Browser on the View menu.
In the Search Text box, type SubType, and then click Search.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now