Deleting files left behind by the Office Integration

The scenario:

  1. open Excel

  2. create a worksheet

  3. check the worksheet into CM using the Office Integration

  4. close Excel

  5. a temp file is left behind in Documents\Micro Focus CM

  6. the file is deleted the next time you open Excel (or another Office application).

The problem

The scenario described above occurs because Excel retains a handle on the file until it has completed closing, at which point the Office Integration has been unloaded and is unable to delete the file. Other Office applications (e.g. Word) release the file before they close allowing the Office Integration to delete the temp file.

A Workaround

While a future version of CM may contain a solution for this problem a work-around available today is to run a powershell script from the windows task scheduler to delete left over files.

The Script

The script below finds all files scheduled for deletion in the managed docs XML file, deletes them and removes the entry from the XML file.

$filePath = $env:APPDATA + "\Micro Focus\Content Manager\OfficeIntegration\managedDocs"

[xml]$cn = Get-Content $filePath

$cn.ArrayOfManagedDocument.ManagedDocument | ? { $_.DeleteMe -eq $true } | % { 
    Remove-Item $_.Path
    [void]$_.ParentNode.RemoveChild($_)
}

$cn.Save($filePath)

The schedule

Not being an admin expert I will not tell you how to configure this script to run for all (or selected) users but I can tell you how I configured it in Windows Task Scheduler. Calling a Powershell script from Windows Task Scheduler is described in this post. In short:

  1. create a task

  2. add an action where program equals powershell.exe and arguments look something like this: -ExecutionPolicy Bypass c:\scripts\file_cleanup.ps1

  3. add a trigger

The Trigger

The trigger could be several of the available options, I chose ‘At log on’ as it was least likely to come into conflict with my use of Office.

Microsoft Office Web Add-ons

Recently I posted re some research we have done into Google Docs and Gmail integration. This post shows the result of similar research into building add-ons for Microsoft Office Online.

Online versions of Office applications are different to the native versions in some not so subtle ways, for example in Office Online your document is saved very frequently, also collaborative editing is encouraged, this impacts the design of a Content Manager add-on.

Currently we have a our SharePoint integration and the Web Client Office Online integration, so any potential Office Web add-on needs to be designed to solve a meaningful business problem. It is even conceivable that Email Link might provide a sufficient server side solution.

If you have an interest in Office add-ons get in touch via the usual channels.