Discussion:
PB and word mailmerge.
(too old to reply)
Steve Cooper
2004-10-26 15:29:04 UTC
Permalink
Could anyone tell me how to do use the mailmerge OpenDataSource function
from within powerbuilder.

In VB this works :

Word.Application.ActiveDocument.MailMerge.OpenDataSource(Name:="",
Connection:="DSN=testdsn;UID=testuid;PWD=testpwd", SQLStatement:="SELECT *
FROM PERSON", SQLStatement1:="")

If I try the same thing in Powerbuilder I get Error calling external object
function opendatasource .... :

obj_mail_merge.OpenDataSource("", "", "", "", "", "", "", "", "","","",
"DSN=testdsn;UID=testuid;PWD=testpwd", "SELECT * FROM PERSON", "")

obj_mail_merge contains the same path as the VB example.

It's probably to do with the empty parameters i'm using being incorrect, but
I've tried all the variations I can think off.

I can use obj_mailmerge.DataSource.Querystring to set the SQL, but I cannot
find away of setting the DSN this way.

Any help most appreciated.

Steve.
Manfred Maier
2004-10-26 17:45:06 UTC
Permalink
Hallo Steve,
have a look to the OLE-Programing

Example (Powerbuilder 6.5):

OLEObject ole_dokument
ole_dokument = CREATE OLEObject

ll_ret = ole_dokument.ConnectToNewObject("Word.Application")
IF ll_ret <> 0 THEN
DESTROY ole_dokument
MessageBox("Ablage", "Kann MS-Word-Verbindung nicht herstellen." + &
"(ret=" + string(ll_ret) + ")", StopSign!)
RETURN
ELSE

******* maybe here *****

ole_dokument.MailMerge.OpenDataSource(Name:="",
Connection:="DSN=testdsn;UID=testuid;PWD=testpwd",
SQLStatement:="SELECT *
FROM PERSON", SQLStatement1:="")


****************************

ole_dokument.Application.Quit
ole_dokument.DisconnectObject()
DESTROY ole_dokument

END IF
--
Manfred Maier
N 48° 22' 36,48" --- E 10° 49' 43,17" --- (WGS84)
Post by Steve Cooper
Could anyone tell me how to do use the mailmerge OpenDataSource function
from within powerbuilder.
Word.Application.ActiveDocument.MailMerge.OpenDataSource(Name:="",
Connection:="DSN=testdsn;UID=testuid;PWD=testpwd", SQLStatement:="SELECT *
FROM PERSON", SQLStatement1:="")
If I try the same thing in Powerbuilder I get Error calling external object
obj_mail_merge.OpenDataSource("", "", "", "", "", "", "", "", "","","",
"DSN=testdsn;UID=testuid;PWD=testpwd", "SELECT * FROM PERSON", "")
obj_mail_merge contains the same path as the VB example.
It's probably to do with the empty parameters i'm using being incorrect, but
I've tried all the variations I can think off.
I can use obj_mailmerge.DataSource.Querystring to set the SQL, but I cannot
find away of setting the DSN this way.
Any help most appreciated.
Steve.
Loading...