Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open XML SDK to edit Active document

Is it possible to use the Open XML sdk to manipulate parts of document which is currently open in the Office app (word/ppt). I know the easiest thing is to use VSTO, but its slow and would involve clipboard use to insert elements, the OXML sdk is direct and simpler.

If somebody could post some code sample that would be great.

Thanks in advance
Rakesh

like image 871
user240282 Avatar asked Mar 14 '10 13:03

user240282


People also ask

What is Open XML SDK?

The Open XML SDK 2.5 simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. The Open XML SDK 2.5 encapsulates many common tasks that developers perform on Open XML packages, so that you can perform complex operations with just a few lines of code.

How do I open Office Open XML in word processing?

#1) Open Windows Explorer and browse to the location where the XML file is located. We have browsed to the location of our XML file MySampleXML as seen below. #2) Now right-click over the file and select Open With to choose Notepad or Microsoft Office Word from the list of options available to open the XML file.

Is Open XML SDK open source?

Today MS Open Tech has announced the release of the Open XML SDK version 2.5 as open source software (Apache 2.0 license) under the stewardship of the . NET Foundation.

How do you add references to open DocumentFormat OpenXml?

Go to your Solution Explorer > right click on references and then click Manage NuGet Packages . Then search in tab "Online" for DocumentFormat. OpenXml and install it. After you can use DocumentFormat.


1 Answers

Yes it is possible to modify an open VSTO document, using the OpenXML sdk 2, then update your open document using the changed xml.

http://msdn.microsoft.com/en-us/library/ff191178.aspx

http://code.msdn.microsoft.com/Improve-Automation-415bff13

Basically you get the xml from a range, treat it as a stream, package it up, use the sdk on the package, then insert the modified xml back by reversing the process.

The wisdom out there is that this common sense usage of the sdk is not possible. However, this is just wrong.

like image 166
Dirk Bester Avatar answered Sep 22 '22 08:09

Dirk Bester