Solved

OlE Automation from PowerBuilder

Posted on 2004-10-07
3
1,653 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Eclipse insufficient memory error 3 119
VB.Net Reusable Form Layout 4 173
How to search for a String with special characters on git 2 152
Angular JS Route 3 100
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: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

756 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