Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error calling MSWord function from a Powerbuilder application

Posted on 2003-12-03
3
Medium Priority
?
833 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 750 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
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 column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

730 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