This project has moved and is read-only. For the latest updates, please go here.

ApplyTemplate problem

Apr 21, 2011 at 2:27 PM

Hi guys. I have a problem.

When i try to create DocX Document with using DocX.ApplyTemplate-metod and save it, then i recive an exception: "Cannot access part because parent package was closed." on line 2297:

using (TextWriter tw = new StreamWriter(settingsPart.GetStream(FileMode.Create, FileAccess.Write)))
                    settings.Save(tw, SaveOptions.DisableFormatting);
at DocX.Save metod. 

My code it is very simple: 

DocX doc = DocX.Create("new.docx");
doc.ApplyTemplate("template.docx");
doc.Save();

What am i doing wrong? 

Thx for your help!

Apr 22, 2011 at 2:29 PM

Hi DragonFire,

You are using this feature correctly, there must be a bug.

Would you mind logging this in the issues section, this is the best way to keep track of bugs. Next time I have a free hour I will debug this.

Cathal

On 21 Apr 2011 14:27, "DragonFire" <notifications@codeplex.com> wrote:
> From: DragonFire
>
> Hi guys. I have a problem.When i try to create DocX Document with using DocX.ApplyTemplate-metod and save it, then i recive an exception: "Cannot access part because parent package was closed." on line 2297:using (TextWriter tw = new StreamWriter(settingsPart.GetStream(FileMode.Create, FileAccess.Write))) settings.Save(tw, SaveOptions.DisableFormatting);at DocX.Save metod. My code it is very simple: DocX doc = DocX.Create("new.docx");doc.ApplyTemplate("template.docx");doc.Save();What am i doing wrong? Thx for your help!
>
>
Apr 22, 2011 at 7:02 PM

Hi, coffeycathal.

Thank you for quick answer! I created topic in issue section.