DocProc assembly problem with locked files

Mar 2, 2009 at 12:23 PM
Hi there,
I am experiencing a frustrating problem with [OpenXml.PowerTools.DocumentBuilder]::BuildDocument(<sources>, <filename>) method.
It seems that when i create a new document as a source and attempt to add it to the Sources parameter, the BuildDocument method generates an exception
When i open (in Word) the *LAST* file added to the sources list, the  "(Read Only)" message follows the docname in the title bar - so it appears to be related to locking.

Code example:
$file = "c:\temp\newfiletocreate.docx"
$content = "new document"
Export-OpenXmlWordprocessing -Text $content -OutputPath $file
$doc = [DocumentFormat.OpenXml.Packaging.WordprocessingDocument]::Open($file, $false)
$src = New-Object OpenXml.PowerTools.Source($doc, $true, $file)
$idx = $sources.Add($src)
[OpenXml.PowerTools.DocumentBuilder]::BuildDocument($sources, "MasterFile.docx"
Anyone else come across this issue.

(interestingly, i can successfully create a new document using "old" documents)

Thanks in advance,
Ben
Mar 18, 2009 at 8:45 PM

Hi Ben,

Thanks for the question - I don't know the answer, but will ping Bob McClellan, who will have insight into this.

One question: why use DocumentBuilder directly instead of the cmdlet Merge-OpenXmlDocument?

-Eric

Mar 22, 2009 at 3:47 PM
I have found the problem and will have a update to fix it soon.