Is there any way I could insert another document?
In VSTO-there is an option to insert document with InsertFile.Looking for something similar here.
The Office JS APIs do not provide an option for inserting a file.
What would be possible is to get the Word Open XML of a file, convert it to the OPC flat file format, then insert that using one of the ooxml methods available.
Related
I'm a newbie in Office365 add-in development, and I'm trying create a poc for a office 365 word add-in and I need to load the add-in with a docx file read from filesystem (alternately from one-drive). Using
Word.run(function (context) {
var body = context.document.body;
...
the document is the current blank word document. Is it possible to start the add-in with a file read from file system? or one the add-in is loaded, can I open a docx file and work on it. I Search in the documentation, but I didn't find anything useful.
Thanks
the method that you want to use in this case is the insertFileFromBase64 method. This method takes as first parameter a base64 encoded docx that then you can insert it.
Check out the reference here
https://dev.office.com/reference/add-ins/word/body?product=word?product=word
note that you need to provide an experience of the user picking a file from the system (using regular HTML file controls) and then base-64 encode it.
Hope this sets you up in the right direction.
I am currently attempting to convert a couple of .NET desktop applications that I have developed into a web application harnessing AngularJS and RESTful services.
One of the key components of these applications is in their ability to generate Word documents on the fly using a .dotx Word template. I am currently exploring the possibility of using a third party library called DocX to generate these Word documents without resorting to using a template.
I guess my question is: Can I use this library to read an existing Word document in .docx format and generate a source code representation of the document? If this is possible could someone point me in the direction of any code samples that I could use? I have looked around and have been unable to find anything that could help me get started.
Generating code representation of the document and using it with DocX seems like a time consuming effort to me. Why not using a template instead and fill it with data at runtime?
I have some experience with Docentric, which is 3rd party OpenXML toolkit. It features an Word Add-in for template design and libraries for document generation and manipulation. It took me less then a week to generate pretty complex documents. If I was in your shoes I would definitely try some 3rd party toolkits. They cost money, but save time so do some math and see it they can be useful for you.
It is possible to read an existing Word document in .docx format with following code
DocX document = DocX.Load(filename)
While it is impossible to generate a source code representation of a document.
Please excuse my ignorance on this subject I am very new to this.
I need to be able to insert images and html that contains tabular data into a word document from a Word Addin. This I have managed to do in its most basic form using the InsertFile method. Word converts the html into its native syntax wordprocessingML which is fine.
However, I need to be able to store some metadata with each inserted object so that it can be regenerated externally and replaced in the document when requested by the user. I have been looking at Open XML but can see how or if it is possible with this either.
Please can you point me in the right direction as to how best I can achieve this.
Thanks in advance.
I have a plugin developed for both MS word and Open Office.
Using the open office plugin it is possible to add a set of Marked references (using XNamed) the xml in content.xml for this mark is:
-<text:p text:style-name="Standard">
<text:reference-mark-start text:name="abc"/>hello
<text:reference-mark-end text:name="abc"/>
</text:p>
when I save this document as .doc or .docx and open it in MS word, the mark reference is lost and only plain text (hello) appears. I want to be able to preserve some information like "abc" here.
Is there a way I can programatically change the xml while open office is converting it to doc format, or while ms word is opening the converted document?
Is there a way(in ms word) to "Realize" that the document being opened was created or edited using open office?
I've used C# interop to develop the word plugin and java UNO for open office.
I ended up providing a "compatibility mode" button in my plugins,for modifying the document before saving and after opening...couldnt find a better solution.
Right now I'm generating HTML with a Perlscript, and then manually converting to DOC in OpenOffice. Actually I have to copy, create new "Text document", paste, save, as it treats HTML and DOC as separate file types, but that's quite unessential. That's very inconvenient.
Is there any automated way I can convert HTML to decent DOC, or some other nice format like HTML I can generate textually and convert to DOC in automated way?
(I'm on OSX)
I can't help you get to .doc, but have you seen the Open XML Format SDK from Microsoft? This will allow you to generate Office 2007 format documents (.docx, .xlsx etc) from .NET code.
Theoretically you may have some luck with this under Mono on OS X, as it doesn't require an installation of Office 2007 (for Windows) to function.
Not sure if this is what you want, but you can fairly easily generate WordML documents with code. WordML is the Word 2003 XML file format. It's NOT the same thing at the Office 2007 Open XML formats. WordML is just one file that's not too hard to create if your just doing fairly basic formatting. You could generate it directly rather than creating the HTML first. You can name the files with a .DOC extension and Word 2003 and later will open them just fine. You can resave them as real .DOC file if you want.
Here's the on-line WordML reference. I can send you some sample code if you'd like.
http://msdn.microsoft.com/en-us/library/aa212812(office.11).aspx
If you really want to create a general file format that could be converted into other formats, creating XML-FO file might be the way to go. There are a number of products out there that can take XML-FO and transform it into other files, such as Word and PDF.
We do use the components of Aspose that are available for .NET and Java. With Java you should be able to use them on OS X, too.
You have to purchase the components (i.e. they are not free), but aside from this, they are really great.