Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OlE Automation from PowerBuilder

Posted on 2004-10-07
3
Medium Priority
?
1,791 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 2000 total points
ID: 12260874
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
ID: 12261251
Thank you very munch. It worked.
0
 
LVL 4

Expert Comment

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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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. …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

886 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