Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Opening Word & Closing

3 posts in Objects Last posting was on 2003-02-13 08:05:43.0Z
Lloyd_Dzinotyiwei Posted on 2003-02-12 22:56:40.0Z
Newsgroups: sybase.public.powerbuilder.objects
From: Lloyd_Dzinotyiwei
Date: Wed, 12 Feb 2003 17:56:40 -0500
Subject: Opening Word & Closing
Lines: 25
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <364_D88E8951853D2E98007E095A85256CCB.007E09A185256CCB@webforums>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub sybase.public.powerbuilder.objects:117
Article PK: 712699

I have Powerbuilder 8.0 with an Oracle 8i backend and I have run into a
problem with a window object. I have a Word OLE object in my window. My
user wants the application to be able to export a contract agreement into
one word document. The contract has different components which are sitting
in different parts of the application.
What I have done is export the individual contract parts into different
files and then using the insertfile macro for MS Word to merge the
documents. This has worked except for one of the word files which has a
table. For some reason it works only when Word is already open before the
export. If you try to export with Word closed, data in that particular file
loses its format.
I use the following code to write to this particular file
ole_doc.Application.Selection.TypeText("Rate Elements")
This has worked I don't understand why it would lose the format when Word
is closed.

I have resolved to opening Word in the application and closing it after the
export has been completed and I don't know how to do.
I know I can use Run(WinWord.exe) but I need to know how I can be able to
close Word after completing the export. Something in the direction of
capturing the handle of the opened Word application and closing it using
DDE.

Acknowledging your co-operation now and in future, I thank you

Sincerely Yours
Lloyd


"De Permentier Davy" <no_spam Posted on 2003-02-13 07:51:13.0Z
Newsgroups: sybase.public.powerbuilder.objects
From: "De Permentier Davy" <no_spam@my_adress>
Subject: Re: Opening Word & Closing
Date: Thu, 13 Feb 2003 08:51:13 +0100
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 193.190.121.69
Message-ID: <364_6S8Jjdz0CHA.199@forums.sybase.com>
References: <364_D88E8951853D2E98007E095A85256CCB.007E09A185256CCB@webforums>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.powerbuilder.objects:115
Article PK: 712683

Hey,

Try this : OLE_Doc.Application.Quit

Don't forget to disconnect from the OleObject after you're done using it!
( OLE_Doc.DisconnectObject() )

HTH,
Davy

<Lloyd_Dzinotyiwei> wrote in message
news:D88E8951853D2E98007E095A85256CCB.007E09A185256CCB@webforums...
> I have Powerbuilder 8.0 with an Oracle 8i backend and I have run into a
> problem with a window object. I have a Word OLE object in my window. My
> user wants the application to be able to export a contract agreement into
> one word document. The contract has different components which are sitting
> in different parts of the application.
> What I have done is export the individual contract parts into different
> files and then using the insertfile macro for MS Word to merge the
> documents. This has worked except for one of the word files which has a
> table. For some reason it works only when Word is already open before the
> export. If you try to export with Word closed, data in that particular
file
> loses its format.
> I use the following code to write to this particular file
> ole_doc.Application.Selection.TypeText("Rate Elements")
> This has worked I don't understand why it would lose the format when Word
> is closed.
>
> I have resolved to opening Word in the application and closing it after
the
> export has been completed and I don't know how to do.
> I know I can use Run(WinWord.exe) but I need to know how I can be able to
> close Word after completing the export. Something in the direction of
> capturing the handle of the opened Word application and closing it using
> DDE.
>
> Acknowledging your co-operation now and in future, I thank you
>
> Sincerely Yours
> Lloyd


"De Permentier Davy" <no_spam Posted on 2003-02-13 08:05:43.0Z
Newsgroups: sybase.public.powerbuilder.objects
From: "De Permentier Davy" <no_spam@my_adress>
Subject: Re: Opening Word & Closing
Date: Thu, 13 Feb 2003 09:05:43 +0100
Lines: 194
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 193.190.121.69
Message-ID: <364_MA2kplz0CHA.331@forums.sybase.com>
References: <364_D88E8951853D2E98007E095A85256CCB.007E09A185256CCB@webforums>
Path: forums-1-dub!forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.powerbuilder.objects:113
Article PK: 712686

Hey again,

I've copied in some sample code for your information. Because I didn't realy
understood your problem (except the closing part). So I hope this sample
code of me can make some things clear.

If you have further problems/questions feel free to ask. I'll be monitoring
this thread for a couple of days...

HTH,
Davy

Instance variables
OleObject iOLE_word, iOLE_doc
BOOLEAN ib_connected = FALSE


public function integer f_set_bookmark (string as_bookmark, string
as_value);

IF NOT ib_connected THEN RETURN -1

iOLE_word.Application.ActiveDocument.BookMarks.Item(as_bookmark).Select
iOLE_word.application.Selection.TypeText(as_value)

RETURN 1

----------------------------------

public function integer f_set_bookmark (string as_bookmark[], string
as_value[]);

Long ll_count, ll_upperbound_bookmark, ll_upperbound_value

IF NOT ib_connected THEN RETURN -1

ll_upperbound_bookmark = UpperBound(as_bookmark)
ll_upperbound_value = UpperBound(as_value)

IF NOT IsNull(ll_upperbound_bookmark) AND NOT IsNull(ll_upperbound_value)
THEN
IF ll_upperbound_bookmark = ll_upperbound_value THEN
FOR ll_count = 1 TO ll_upperbound_bookmark
This.f_set_bookmark(as_bookmark[ll_count], as_value[ll_count])
NEXT
RETURN 1
END IF
END IF

----------------------------------

public function integer f_save_as_document (string as_doc);

//as_doc must contain the full path !

IF NOT ib_connected THEN RETURN -1

iOLE_word.Application.ActiveDocument.SaveAs(as_doc)

RETURN 1

-----------------------------------

public function integer f_disconnect ();

Integer li_rt

IF NOT ib_connected THEN RETURN 0

iOLE_word.Application.Quit

li_rt = iOLE_word.DisconnectObject()

CHOOSE CASE li_rt
CASE -1
//Invalid call: the argument is the Object property of a control
RETURN -1
CASE -9
//Other error
RETURN -1
END CHOOSE

ib_connected = FALSE

RETURN 1

-----------------------------------------

public function integer f_open_document (string as_doc);

Integer li_rt

IF NOT ib_connected THEN RETURN -1

//Open Word Document
iOLE_word.Documents.Open(as_doc)

RETURN 1

-------------------------------------------

public function integer f_set_word_visible (boolean ab_visible);

IF NOT ib_connected THEN RETURN -1

iOLE_word.Visible = ab_visible

RETURN 1

--------------------------------------------

public function integer f_connect (string as_doc, boolean ab_visible);

Integer li_rt

IF ib_connected THEN RETURN 0

iOLE_word = CREATE OleObject

li_rt = iOLE_word.ConnectToNewObject("word.application.9")

CHOOSE CASE li_rt
CASE -1
//Invalid call: the argument is the Object property of a control
RETURN -1
CASE -2
//Class name not found
RETURN -1
CASE -3
//Object could not be created
RETURN -1
CASE -4
//Could not connect to object
RETURN -1
CASE -9
//Other error
RETURN -1
CASE -15
//MTS is not loaded on this computer
RETURN -1
CASE -16
//Invalid Call: this function not applicable to OLETxnObject
RETURN -1
CASE ELSE
ib_connected = TRUE
END CHOOSE

This.f_set_word_visible( TRUE )

//Open document
This.f_open_document( as_doc )

//Activate Word application
iOLE_word.Activate

//Set Visbility
This.f_set_word_visible( ab_visible )

RETURN 1

<Lloyd_Dzinotyiwei> wrote in message
news:D88E8951853D2E98007E095A85256CCB.007E09A185256CCB@webforums...
> I have Powerbuilder 8.0 with an Oracle 8i backend and I have run into a
> problem with a window object. I have a Word OLE object in my window. My
> user wants the application to be able to export a contract agreement into
> one word document. The contract has different components which are sitting
> in different parts of the application.
> What I have done is export the individual contract parts into different
> files and then using the insertfile macro for MS Word to merge the
> documents. This has worked except for one of the word files which has a
> table. For some reason it works only when Word is already open before the
> export. If you try to export with Word closed, data in that particular
file
> loses its format.
> I use the following code to write to this particular file
> ole_doc.Application.Selection.TypeText("Rate Elements")
> This has worked I don't understand why it would lose the format when Word
> is closed.
>
> I have resolved to opening Word in the application and closing it after
the
> export has been completed and I don't know how to do.
> I know I can use Run(WinWord.exe) but I need to know how I can be able to
> close Word after completing the export. Something in the direction of
> capturing the handle of the opened Word application and closing it using
> DDE.
>
> Acknowledging your co-operation now and in future, I thank you
>
> Sincerely Yours
> Lloyd