OlE Automation from PowerBuilder

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
vasunaniAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
falvaro3Connect With a Mentor Commented:
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
 
vasunaniAuthor Commented:
Thank you very munch. It worked.
0
 
falvaro3Commented:
Vasunani, don't forget to accept the answer.  If you need help, http://www.experts-exchange.com/help.jsp#hi68
;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.