Jump to content

Problem with word.application objekt


Recommended Posts

Hi everybody.

Im writing a small script designed to run at all the computers where i work. The script is supposed to update everybodys contactlist and mailsignature.

Anyway. I got the entire script to work perfectl and it goes exactly what i want, but there is one problem.

The mailsignature part is based on a small part of code that i copied here from the forum (thanx water).

The cod is as follows

Local $oOL_Word = ObjCreate("Word.Application")
Local $oOL_Doc = $oOL_Word.Documents.Add()
Local $oOL_Selection = $oOL_Word.Selection
$oOL_Selection = $oOL_Doc.Range()
$iResult = _OL_MailSignatureCreate("mailsignature_1", $oOL_Word, $oOL_Selection, False, False)

As i said. It works perfectly. The problem is that the program leaves the winword.exe process running after the program has finished, witch means that if the script run 2 times per day, you will have alot of winword applications in a few days. When you shutdown the system you have to forcefully close Word. That means that when you start word next time word "reacreates unsaved dockuemts" and present the user with alot of "unsaved documents". I can close it with processclose("winword.exe") but then the users who are runningw word when the script runm will see thair work go upp in smoke.

I guess there is some way to close the $oOL_Word object. But i dont know that mutch about this kind of programming to know what to do. Any idees?

Link to comment
Share on other sites

Use

$oOL_Word.Quit
$oOL_Word = 0
$oOL_Doc = 0
$oOL_Selection = 0

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Insert

$oOL_Doc.Saved = True
before
$oOL_Word.Quit

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Works like a charm. Thank you!

I tried looking trough the helpfile, but all i find is functions. And theese are not functions in that manner right? So is there some kind of tutorial och refference guide or something?

Link to comment
Share on other sites

MSDN is your friend. Word 2007 or Word 2010.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...