This project is read-only.

PowerEventReceivers V2.0 / Save Doc from Word

Mar 5, 2009 at 4:49 PM
Hi,

i try to use the PowerEventReceivers to trigger, after a Document is saved to a Library from Word2007 but nothing happens.
I tried the ItemAdded / ItemCheckedIn.... with the same result.

When i use the "Upload" Button to save the Document to the library, the events are triggerd...
Am I'm missing something? What i have to do exactly to use a powershell script in the powereventreceiver, when saving a document from Word?

Regards,

Michael
Mar 5, 2009 at 6:54 PM
Hey Michael,

should work with ItemAdded. You can easily dump within a folder where your app pool has write permissions.
If there is an error in your script you should see it in the systems event log.

After I created a new document and saved via word, I find the dump file as expected (C:\dump_added.txt)

function ItemAdded
{
 $item | Out-File "C:\dump_added.txt"
}

function ItemUpdated
{
 $item | Out-File "C:\dump_updated.txt"
}

bye,

Christian

Mar 6, 2009 at 8:59 AM
Hey Christian,

thank you for your response!

The solution was easy: there was an bracket } to much  at the end of my script....

Bye,

Michael

Mar 6, 2009 at 10:41 AM
Hello Michael,

try the iLove SharePoint PowerGUI Launcher. You have to install PowerGUI and the PowerGUI Launcher (ActiveX) on your client.
After this you can edit your scripts in PowerGUI :-)

Bye,
christian

Apr 22, 2009 at 5:49 AM
Hello!

I have the same problem with saving doc(x) files from MS Word 2007... :(
I use this script:
 

function ItemAdded

{

 $this.DisableEventFiring();

 $ids = $item["ID"];

 $item["OutNumber"] = "Agreement 2009/$ids";

 $item.Update();

 $this.EnableEventFiring();

}

In case of Uploading document by standard WEB form - it works FINE, but if I save document from WORD it doesn't work :(
What did I miss?

Jul 9, 2009 at 2:46 PM

Hello!

I have a similar problem, I created a script to write the value of a Lookup field into a Text field

Here's the code: Project is the lookup field to the Projects list, the Project Symbols is the text field tha will contain tha value of Project

function ItemAdding
{

$uniqueValue = $properties.AfterProperties["Project"]
 
 $projectlist = $web.Lists["Projects"]

 $item = $projectlist.GetItemById($uniqueValue)
 
 $properties.AfterProperties["Project Symbols"] = $item["Project"]

}

same code for ItemUpdating.

From web (Edit Properties) it runs perfectly,

If I modify the lookup field Project in MS Word 2007 and save the script run and the Project Symbols field is compiled, and in the document library you see the updated value.

But if I reopen the document in MS Word in the Project Symbols field I see the old value not the new one.

It seems that MS Word doesn't read the properties from the document library,

if I use the Edit Properties of the document library and than reopen MS Word the field is correctly updated.

I have missed something or is a MS Word bug?

Regards.

Valerio