Jump to content
Sign in to follow this  
Tjalve

Problem with word.application objekt

Recommended Posts

Tjalve

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?

Share this post


Link to post
Share on other sites
water

Use

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

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tjalve

Damn your fast...

It works, but i get a popup windows asking me if i want to save the document befor closing.

Share this post


Link to post
Share on other sites
water

Insert

$oOL_Doc.Saved = True
before
$oOL_Word.Quit


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tjalve

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?

Share this post


Link to post
Share on other sites
water

MSDN is your friend. Word 2007 or Word 2010.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tjalve

This is waaay out of my leuge... thanx anyway :oops:

Share this post


Link to post
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
Sign in to follow this  

×