views:

719

answers:

11

I have been searching for several hours but i couldn't find anything about this... Basically I would like to create a template or plug-in for word 2007 that would allow someone to create new pages for a CMS. What I have in mind is something similar to blog post template. I know how to create a basic template but I can't find a way to publish the created document using a publish button inside the Word.

thnx in advance

+4  A: 

Word is horrible, horrible, horrible. Your site will define clear styles, yet Word will output nasty HTML that won't match your website's CSS definitions.

Your best bet therefore is to have a means to drop the Word file into the site, and have code programmatically analyse it and transform it into site-valid HTML. In Java you could use Apache POI, but that's very raw still. Might be a lot easier in a Microsoft centric world.

Far better, in my opinion, is to force people to learn Markdown, or BBCode, or HTML, or to use a Styled HTML Editor in your CMS - cut and paste plain text in, then style with the CMS defined styles.

JeeBee
+2  A: 

Ugh I just threw up in my mouth a little.

Buuuut... what version of Word are you using? Have you considered using its export as HTML function and plugging the results into your CMS?

Andrew G. Johnson
Andrew, doesn't the question mention Word 2007 as the version?
James Piggot
+6  A: 

I understand what you are trying to achieve, but Word is the wrong starting point. I would start with a much more basic text editor.

Galwegian
I already have a web text editor and I also want to allow the user to use his Office to do the work. But please answer only if you have some information on the subject, not just to tell me how bad choice this might be.
@Hagalaz - sorry you feel that way - I was just trying to provide some advice. I would not use Word as a starting point for your project if I were you. Good luck with it anyway!
Galwegian
I agree with Galwegian, don't go with Word.
unforgiven3
+2  A: 

I already have a web text editor and I also want to allow the user to use his Office to do the work. But please answer only if you have some information on the subject, not just to tell me how bad choice this might be.

We all have information on the subject, and we're telling you that Word is an awful choice. That is our information on the subject. You should seriously reconsider.
unforgiven3
+1  A: 

You can do what you want if you use SharePoint 2007 as your CMS. You can set up a blog on SharePoint 2007 and post to the blog from Word. If you use Office 2007 on the client end then you will get some nice buttons like "post to my blog" etc.

If you can't use SharePoint or are talking about an existing CMS, you have a lot of hurdles to jump through. This is a major undertaking and not something you can get a simple answer out of Stack Overflow.

Sam Meldrum
Yes, it is an existing CMS. What I want to know is if this is possible and if someone has more information or links on the subject, nothing more.
+3  A: 

As you are using Word 2007 you can export the document as XML and then use XSLT to generate the HTML.

If your CMS has an API or import facility you could convert the output from Word to suit that interface.

You can write a Word macro to add a Publish button/menu option to Word that will generate the correct output.

James Piggot
+1  A: 

Have you considered using one of the freely available Javascript WYSIWYG Editors such as TinyMCE http://tinymce.moxiecode.com/? When configured with all the options, it has an impressive amount of functionality and the interface is very similar to Word. I realize this doesn't directly answer your question, but as others have pointed out starting from Word is going to be difficult.

+3  A: 

It's not a bad idea since it's all about the end user. If Word produces bad HTML, you should just make it semantic correct before posting it to the CMS.

I've never done this but I'm sure that it's possible to with .NET via the "Word 2007 Addin"-template (assuming Office 2007).

Good luck!

Patrik
A: 

For some reason this is a feature that Excel enjoys but not Word. Excel can can automatically publish an HTML file version of your document when you save it.
Unfortunately Word seems to only be able to achieve this functionality when using Sharepoint, which is a shame because it can be quite useful.

What you can do, short of creating your own add-in is to add a bit of code to your template to create a HTML copy of your document whenever the user saves it.

  • First, make sure your template is macro-enabled (saved as .dotm file).
  • Second, while editing the template in Word, open the VBA code editor (ALT-F11)
  • In the project list double-click on your document to open its code-behind file.
  • Add the following bit of code to it, modifying the ActiveDocument.SaveAs path to something more appropriate to you, like a shared network folder where your CMS exposed by your CMS.

    Sub FileSave()
        ' First Save the main document
        ActiveDocument.Save
        ' Now we create a new document based on the current one
        Selection.WholeStory
        Selection.Copy
        Documents.Add
        Selection.PasteAndFormat wdPasteDefault
        ' Save it as HTML and close it
        ActiveDocument.SaveAs "c:\temp\mydoc.html", fileformat:=wdFormatHTML
        ActiveDocument.Close
    End Sub
    

This will copy the original file into a blank new one that will be saved to HTML and closed before returning to the original file.

You can check some of the options to the Documents.Add if you want to use a different template than the normal one.

Security

because this template contains macros, you will have to install it with the other templates where Word expect them.
If you don't, then you'll get a security warning.
To avoid getting it, you can add the path where your templates are located to the list of Trusted Locations under Word's Options > Trust Center > Trust Center Settings > Trusted Locations.

Renaud Bompuis
+1  A: 

I've been on a team that wrote a Word addin for a custom CMS system. It was written in VB6 and was able to take a Word document and turn basic formatting information - lists, bold, italic and even tables into HTML, which was uploaded to the server. It didn't create new pages or manage the site in the addin though.

I would definitely avoid choosing Word as the editor for your CMS from my experience. The biggest issue is each time you want to update the addin you have to redistribute it to the company or companies using it. You can do this is as an IE active-x control but it's far easier just to handicap the user to a limited set of styling options via a Javascript editor.

Word does have a powerful API for manipulating your content with, however we needed to disable so many options in Word to avoid unwanted fonts and so on, it resembled Wordpad more than Word in the end.

If it's a greenfield project and you have the time, I would infact recommend using Silverlight 4.0 over a Javascript editor. Version 4.0 has a richtextbox control built in, plus there is also the excellent Vectorlight one.

Chris S
+1  A: 

May be it helps you, umbraco CMS allow editing with Microsoft Word.

FFire