Solved

OlE Automation from PowerBuilder

Posted on 2004-10-07
3
1,699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
falvaro3 earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

623 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