none
Apps for Office -- Open a document programmatically RRS feed

  • Question

  • The msdn site provides the following example to open a word document programmatically:

    this.Application.Documents.Open(@"C:\Test\NewDocument.docx", ReadOnly:true);

    It also states

    "Applies to: The information in this topic applies to document-level projects and application-level projects for Word 2013 and Word 2010."

    What is the equivalent for this in "Apps for Office"?

    The objective is to create a button on Home.html with JavaScript code in Home.js that can open a document.

    Regards,

    Ojix

    (File names above are the defaults created using Visual Studio 2013)





    • Edited by ojix Saturday, April 4, 2015 3:42 PM
    Saturday, April 4, 2015 5:53 AM

Answers

  • There is no such equivalent. Office Apps work in the context of documents. You need to develop an add-in if you want to automate Word.
    • Marked as answer by ojix Saturday, April 4, 2015 3:26 PM
    Saturday, April 4, 2015 6:11 AM

All replies

  • There is no such equivalent. Office Apps work in the context of documents. You need to develop an add-in if you want to automate Word.
    • Marked as answer by ojix Saturday, April 4, 2015 3:26 PM
    Saturday, April 4, 2015 6:11 AM
  • Hi Eugene,

    Thanks for the confirmation. More questions:

    1. Is there any way to create an Add-In that exposes its API such that it may be accessed from "Apps for Office" in JavaScript? Could such an Add-In expose opening a file as a capability?

    2. Is there a way to open an App for Office after opening a document?

    Regards,

    Ojix

    Is it OK to ask such follow-up questions here? Or should these be separate questions? -- Ojix




    • Edited by ojix Saturday, April 4, 2015 3:44 PM
    Saturday, April 4, 2015 3:26 PM
  • Hi Ojix,

    First of all, I'd recommend asking separate questions in new forum threads. Thus forum readers may recognize questions and answers easily.

    1. There is no easy way of communicating between Office Apps and another software (for example, COM add-ins). Note, you can access all running COM add-ins using the COMAddIns property of the Application class.

    2. Nope. The Office extensibility model doesn't provide anything for that (communications between COM add-ins and Office apps). You can try to access the web browser control which hosts  your Office app.

    Saturday, April 4, 2015 7:01 PM