none
Word file with Add-In or Word template? RRS feed

  • Question

  • Hello,

    I'm totally new to this, so please bear with me. I want to know the difference between choosing "Word with Add-In" versus a "Word template." I'm using VS2010 and Word 2010. I need to create code that will help me to convert incoming SGML files. SGML is, of course, just tagged ASCII, like XML. But, I need to take these SGML documents and convert them into pretty, structured Word documents with paragraph styles.

    So, if I choose Project/Office/Word 2010 Add-In, I'll end up with a Word file with an Add-In pulldown that I can execute code from. If I choose Project/Office/Word 2010 template, will I get that Add-In pulldown? And, if not, how will I execute the code in that template. Will I literally run a macro like in VBA?

    It's because, whatever I choose, I'll be opening up raw files to act on that I'm confused. I've assumed that, because I'll be opening up other files, I should choose a template, because, then, the code in my template can be used with the newly opened files. If I choose a Word file, though, I'm not sure that any code I put into it will be available to me when I open up another file.

    Thanks,

    Peter

     

    Friday, April 29, 2011 12:20 PM

Answers

  • Hi Peter

    This is the wrong place to ask that. Try the forums on OpenXMLDeveloper.org and the Open XML SDK forum.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by pb4072 Monday, May 2, 2011 11:13 AM
    Monday, May 2, 2011 5:53 AM
    Moderator

All replies

  • Hi Peter

    It would probably be best to back up a step and ask: do you need to interact with the Word application at all?

    The Open XML file format lets you generate documents without the Word application, using the standard .NET Framework Packaging and XML namespaces. In essence, you ought to be able to perform a transform on the SGML to Word Open XML, "pack it up" to a docx and pass the finished product to the user.

    You'll find more information at OpenXMLDeveloper.org and in the Open XML SDK forum.

    If for some reason that does not meet your needs and you want to interact with the user in the Word application, then I believe an Add-in might be more appropriate. The add-in lets you provide tools to the user for use with all Word documents. Please note that an add-in will not give you "a Word file with an Add-in pulldown" (not sure what you mean by the last, but it won't give you a Word file, in any case). A VSTO add-in compiles to a COM dll and supporting files.

    With a VSTO template you're basically giving the user a tool for a specific type of document, such as a report. In this case, the VSTO dll code is linked into the template (and the document).

    In both cases, you extend the UI (Ribbon, Custom task pane, etc.) to allow the user to trigger the tools you provide.


    Cindy Meister, VSTO/Word MVP
    Friday, April 29, 2011 2:12 PM
    Moderator
  • Hmm. That's probably a good question. No, I'm not wedded to having an interactive application with Word.

    I'd need to read up on Open XML. I'm a bit leery of it. Doesn't Open XML data have to parse with a schema? When you say "transform," do you mean use VB to do the transformation. Or, should I used XSLT or something like that?

    Regarding the "add-in" stuff, I just recall seeing an actual "add-in" pulldown when I happened to have a Word application installed that used it. When I pulled down on "add-ins," I saw that application's tools. I've since uninstalled that application and now I don't see the "add-in" pulldown anymore.

    I understand now, from what you've said, that I can indeed place tools into a Word file or template for the user.

    Thanks for your help, Cindy. I'm going to now go and read up on OpenXML.

     

    -Peter

     

    Friday, April 29, 2011 2:32 PM
  • Hi Peter

    <<I'd need to read up on Open XML. I'm a bit leery of it. Doesn't Open XML data have to parse with a schema? When you say "transform," do you mean use VB to do the transformation. Or, should I used XSLT or something like that?>>

    No, you don't need to create a schema. The requirement is that the XML you generate complies with the schemas written by Microsoft for the OpenXML file formats (IOW you have to follow the rules - no surprise, I think). Basically, instead of running the Word application, dropping text "onto" the document then formatting it, you write it straight to a text file. Think in terms of RTF or HTML or even the proprietary SGML with which you're already familiar. You just put a different set of tags around it, to tell it it's in a Word document body and formatted thusly.

    You can use whichever tools are most comfortable for you. An XSLT would work, or building the file using the DOM, or even LINQ, I'd imagine (you're getting a bit out of my area of expertise). In addition, VS.NET provides the Open XML SDK to "smoothen the ride" for .NET developers.

    <<Regarding the "add-in" stuff, I just recall seeing an actual "add-in" pulldown when I happened to have a Word application installed that used it.>>

    Mmm, perhaps you mean the Add-ins tab in the Ribbon? You can place controls in that Tab, or create your own Tab(s) if you go the Add-in route.

    <<I understand now, from what you've said, that I can indeed place tools into a Word file or template for the user.>>

    mmm, I'm still not certain we understand each other completely on this point. IF you use VSTO you won't be placing any tools into a Word file or template. Either Word will be loading your tools as it loads (an add-in) or loading them into its interface when you create a document from the VSTO template. But in both cases nothing is stored IN a Word document.

    Only VBA code stores in "Word files".


    Cindy Meister, VSTO/Word MVP
    Friday, April 29, 2011 3:50 PM
    Moderator
  • Thanks, Cindy. So, can you please point me to someplace where I can find out more about the Microsoft spec for OpenXML? If I open up one of my Word files here on my computer, could I get a good idea of how this stuff is structured? I'm intrigued by how any stylistic information is placed in the XML.

    Yes, with that particular application, it created an Add-in pulldown on my ribbon. And, once I uninstalled it, that pulldown went away.

    Regarding the last point . . . well, when I first experimented with creating a Word add-in file or a Word template, I didn't actually see that there really is a toolbox there for me to use, as there was when I create a form project. But, I looked a bit closer and now I do indeed see a toolbox. So, I assumed that, with that toolbox, I can place tools into the Word file or Word template file. So, are you saying that none of those tools will actually be in my Word document until I load the add-in, or, that I create the Word document from my VSTO-created template.

    Whew.

    Thanks,

    Peter

     

     

    Friday, April 29, 2011 5:59 PM
  • Hi Peter

    More information about OpenXML: OpenXMLDeveloper.org, the Open XML SDK forum, at a very basic level, indirectly, in this article about Ribbon development ("how do I open and look at..."), http://msdn.microsoft.com/en-us/office/bb265236...

    <<So, I assumed that, with that toolbox, I can place tools into the Word file or Word template file. So, are you saying that none of those tools will actually be in my Word document until I load the add-in, or, that I create the Word document from my VSTO-created template.>>

    For learning more about how VSTO is designed and works I recommend the on-line documentation, starting here: http://msdn.microsoft.com/en-us/library/23cw517s.aspx

    No, nothing you place "on" a document will actually be there unless the VSTO solution can load successfully. Actually stored in the document is a graphical "picture" of the ActiveX placeholder that "wraps" the .NET control at run-time.


    Cindy Meister, VSTO/Word MVP
    Saturday, April 30, 2011 6:20 AM
    Moderator
  • OK. I've read up on the Word xml format. I don't see real definitions of the schema components anywhere, meaning, what the actual Word xml elements are. Like with this example code:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
    <w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:o="urn:schemas-microsoft-com:office:office" 
      xmlns:o12="http://schemas.microsoft.com/office/2004/7/core"
      xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
      xmlns:m="http://schemas.microsoft.com/office/omml/2004/12/core" 
      xmlns:v="urn:schemas-microsoft-com:vml" 
      xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/3/wordprocessingDrawing" 
      xmlns:w10="urn:schemas-microsoft-com:office:word" 
      xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/3/main"> 
      <w:body> 
      <w:p> 
       <w:r w:rsidR="002847EC"> 
       <w:t>Word 2007 rocks my world!</w:t> 
       </w:r> 
      </w:p> 
      </w:body> 
    </w:document> 

    What is <w:body>? What is <w:p>? What is <w:r>? What is <w:t>?

    Thanks,

    Peter

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Monday, May 2, 2011 3:06 AM
  • Hi Peter

    This is the wrong place to ask that. Try the forums on OpenXMLDeveloper.org and the Open XML SDK forum.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by pb4072 Monday, May 2, 2011 11:13 AM
    Monday, May 2, 2011 5:53 AM
    Moderator
  • OK. Thanks for all your help, Cindy.
    Monday, May 2, 2011 11:13 AM