Link to home
Start Free TrialLog in
Avatar of Lloyd Charlier
Lloyd CharlierFlag for United States of America

asked on

Programmatically creating Office 2013 documents (Word, Excel, PowerPoint) from template files

I have written VSTO addins for Office 2013 (and later) apps that integrates them with a 3rd-party enterprise content management (ECM) system - providing the user with ECM analogs for all of the native file I/O operations (e.g. New, Open, Save, Save As, etc...).  That said, all of the functions proved quite simple to implement until I got to the New function (i.e. the ability to create a new document (Word, PowerPoint or Excel) from a supplied template.  In Word, this was simple:

this.Application.Documents.Add(filename);

Open in new window


Voila!  The user selects a Word template file (i.e. filename) and Word subsequently creates a Word document based on the selected template file.  Naively, I thought the PowerPoint and Excel object models would be similar to Word's - I was wrong.  There doesn't appear to be any method similar to Add (e.g. Presentations.Add, Workbooks.Add) that performs the same function.  While I did find examples on the web of creating a PowerPoint document from a specified template file, the approach taken was radically different than that required by Word, involved using the Open XML SDK and was significantly more convoluted.

Does anyone know of a simpler way (in C#) of creating both Excel and PowerPoint documents from specified template files (i.e. .xltx, .xlt, .xltm, .potx, .pot, .potm files)?  I look forward to everyone's feedback!
SOLUTION
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lloyd Charlier

ASKER

Thanks guys - that did the trick!