Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 863
  • Last Modified:

Error calling MSWord function from a Powerbuilder application

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
Meena_kumari
Asked:
Meena_kumari
1 Solution
 
sajuksCommented:
can u post a part of ur code so that it could be more understandable ?
0
 
Meena_kumariAuthor Commented:
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
 
mdhamptonCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now