Solved

Error calling MSWord function from a Powerbuilder application

Posted on 2003-12-03
3
732 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
ID: 9865348
can u post a part of ur code so that it could be more understandable ?
0
 

Author Comment

by:Meena_kumari
ID: 9865651
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
ID: 9903720
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Safearray problem c++ 4 88
Adding ribbon in custom Tab in word 2007 using VBA editor 10 75
error when checking java version 4 4,705
What xml editor to use. 8 99
In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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…

820 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