Solved

OlE Automation from PowerBuilder

Posted on 2004-10-07
3
1,606 Views
Last Modified: 2013-12-26
I have a PowerBuilder application that opens a existing template in word and fills up wit Data depending on the actions taken by the user, then prints it and saves it under a different file name and closes the template. This used to work fine till we had a windowsXP upgrade.
It still works but when there is any other word document open on the users machine, after printing it it displays a message box telling "the file is in use by another Application or user C:\Documents and Settings\...\normal.dot"
and when the user clicks OK it tries to save changes to the "Normal.dot".

I think for some reason instead of opening the Template we have the application is opening up a document in Normal.dot and is prompting to save changes to the global template.
It works fine if there is know other word document open on the users machine.
How can I suppress this? Why does this happen? Please tell me how I can just open my own template and write something to it and save it as another document with out having to open it up with Normal.dot.
Following is the PB code.

//***************************************//
// Instaniate OLE Object
OLEObject iole_wordapp

// Create OLE Object
iole_wordapp = CREATE OLEObject

// Connect to MS Word 97
iole_wordapp.ConnectToNewObject ( "word.Application")

// Make MS Word 97 Visible
iole_wordapp.application.visible = True
      
//Get all needed data from database
//Depending on the user actions pick the right word ttemplate.
iF ls_action_cde = "Credit"  then
    iole_wordapp.Documents.Add("C:\FullPath\Credit_ltr.dot")           //had the full path of the Template
Else
    iole_wordapp.Documents.AddC:\FullPath\Debit_ltr.dot")                     //had the full path of the Template

//Populate the Word template with data using Bookmark function
//Example
//Populate Company name
IF iole_wordapp.ActiveDocument.Bookmarks.Exists("Name_1") and ls_poc_cmp_nam_1 <> "" Then
      iole_wordapp.ActiveDocument.Bookmarks.Item("Name_1").Select
      iole_wordapp.ActiveWindow.Selection.InsertAfter("Name of the Company")
end if
//After adding all the required data on the word Document print it
//Then Print the Document to the defaault printer
iole_wordapp.ActiveDocument.PrintOut
//wait 25 seconds
time  lt_start
lt_start = now()
int  i_sec
li_sec = 0
DO UNTIL li_sec > 25
      li_sec = SecondsAfter ( lt_start, now() )
LOOP
//SaveAs a different filename
iole_wordapp.ActiveDocument.SaveAs("VISS_letter.doc")

// Closes the Activedocument
iole_wordapp.ActiveDocument.Close()
//Quit word
iole_wordapp.quit ( )

//Disconnect from object
iole_wordapp.DisconnectObject ( )

//Destroy word application
destroy iole_wordapp

//*******************************************//

Please help ASAP.

Thank you
0
Comment
Question by:vasunani
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
falvaro3 earned 500 total points
Comment Utility
See http://support.microsoft.com/default.aspx?scid=kb;en-us;285885

    * Before you quit Word or transfer control to the user, set the Saved property of the Normal.dot template to True as follows:

Application.NormalTemplate.Saved = True
                              
      -or-

    * Set the SaveChanges argument for the Quit method as follows:

Application.Quit SaveChanges(0)
                              
0
 

Author Comment

by:vasunani
Comment Utility
Thank you very munch. It worked.
0
 
LVL 4

Expert Comment

by:falvaro3
Comment Utility
Vasunani, don't forget to accept the answer.  If you need help, http://www.experts-exchange.com/help.jsp#hi68
;)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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. …
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…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now