locked
Word automation in C# RRS feed

  • Question

  • Hi All,

    Im a newbie trying my hands on word automation in c#, I need to extract various contents from unprotected regions of a doc as shown in following example : 

     

    Eg.

    Section Title - <ABCCC>    ->  <protected area>

    ------------------

    ------------------                 -> contents keyedin by users  <unprotected area>

     

     

    Section Title - <XYZZZ>     ->  <protected area>

    ------------------

    ------------------                 -> contents keyedin by users  <unprotected area>

     

    1. How to specify more than one protected area which is editable by owner & not by everyone(i have used the protect method but unfortunately it doesnt allow to specify multiple protected regions at once) ??

    2. Also How can i mark the above content regions in the doc to extract data from them, should i use bookmarks?? if so how do i add custom bookmarks & extract data from them ??


    I need to generate such document first and later extract data from the unprotected regions.

    Can anybody guide me through this?? Any kind of assistance would be priceless !!


    Many Thanks
    Peter

     

    • Moved by Alan_chen Tuesday, November 23, 2010 8:08 AM (From:Visual C# General)
    Saturday, November 20, 2010 12:47 PM

Answers

  • Hi Peter

     

    Please use the below code and guidelines to accomplish this word automation.

    http://www.midnightprogrammer.net/post/Word-Automation-in-C.aspx

     

    Hope this helps!!

     


    www.midnightprogramer.net
    • Marked as answer by Amy Li Monday, November 29, 2010 2:46 AM
    Monday, November 22, 2010 3:43 PM
  • Hi All,

     Please let me know how should i approach to this problem??

     I need to create a webservice for the same, shall i proceed with Interops COM, VSTO or OpenXML ??

     Automation Web Service contains two parts (as listed in above example) :

    1. Generation of Document
    2. Extraction of Contents from editable areas (usually in the HTML format which can be later displayed in a browser)

    I would also like to know the Pros & Cons of various approaches.


    Hi Pater

    If you're working from a web service, I recommend you use the OpenXML file format.

    Automation of Office applications from a server is not recommended, as Office was designed for user interaction. The OpenXML file format was designed expressly for the purpose you propose.

    But when you ask for assistance in the OpenXML SDK forum on MSDN be sure to mention the versions of Word you intend to support, as that will affect what features are available.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Amy Li Monday, November 29, 2010 2:46 AM
    Tuesday, November 23, 2010 8:35 AM
  • Hi Peter

     

    Yes, it is possible to do in .docx format also.

     


    www.midnightprogramer.net
    • Marked as answer by Amy Li Monday, November 29, 2010 2:45 AM
    Tuesday, November 23, 2010 9:38 AM
  • Hi Peter

    <<Thanks alot for the reply. Does the OpenXML object format supports protection feature??>>

    It should as the file format reflects everything possible in the application, but I recommend you ask in the Open XML SDK forum where you'll find the specialists.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Amy Li Monday, November 29, 2010 2:45 AM
    Wednesday, November 24, 2010 5:16 PM

All replies

  • Hi,

    Somebody Please put some light on this.

     

    Many Thanks

    Peter

    Monday, November 22, 2010 6:10 AM
  • Hi All,

     

    Please let me know how should i approach to this problem??

     

    I need to create a webservice for the same, shall i proceed with Interops COM, VSTO or OpenXML ??

     

    Automation Web Service contains two parts (as listed in above example) :

    1. Generation of Document

    2. Extraction of Contents from editable areas (usually in the HTML format which can be later displayed in a browser)

     

    I would also like to know the Pros & Cons of various approaches.

    Any kind of assistance would be priceless !!

     

    Many Thanks

    Peter

    Monday, November 22, 2010 11:51 AM
  • Hi Peter

     

    Please use the below code and guidelines to accomplish this word automation.

    http://www.midnightprogrammer.net/post/Word-Automation-in-C.aspx

     

    Hope this helps!!

     


    www.midnightprogramer.net
    • Marked as answer by Amy Li Monday, November 29, 2010 2:46 AM
    Monday, November 22, 2010 3:43 PM
  • Hi All,

     Please let me know how should i approach to this problem??

     I need to create a webservice for the same, shall i proceed with Interops COM, VSTO or OpenXML ??

     Automation Web Service contains two parts (as listed in above example) :

    1. Generation of Document
    2. Extraction of Contents from editable areas (usually in the HTML format which can be later displayed in a browser)

    I would also like to know the Pros & Cons of various approaches.


    Hi Pater

    If you're working from a web service, I recommend you use the OpenXML file format.

    Automation of Office applications from a server is not recommended, as Office was designed for user interaction. The OpenXML file format was designed expressly for the purpose you propose.

    But when you ask for assistance in the OpenXML SDK forum on MSDN be sure to mention the versions of Word you intend to support, as that will affect what features are available.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Amy Li Monday, November 29, 2010 2:46 AM
    Tuesday, November 23, 2010 8:35 AM
  • Hi Prashant

    Thanks alot for the reply but is it possible to implement the same in docx format ?? as need to disable few buttons/menus in the ribbon.

     

    Hi Cindy

    Thanks alot for the reply. Does the OpenXML object format supports protection feature??

    http://office.microsoft.com/en-us/word-help/allow-changes-to-parts-of-a-protected-document-HA010372706.aspx

    Im currently using MS Word 2007. 

     

    Tuesday, November 23, 2010 9:29 AM
  • Hi Peter

     

    Yes, it is possible to do in .docx format also.

     


    www.midnightprogramer.net
    • Marked as answer by Amy Li Monday, November 29, 2010 2:45 AM
    Tuesday, November 23, 2010 9:38 AM
  • Hi Peter

    <<Thanks alot for the reply. Does the OpenXML object format supports protection feature??>>

    It should as the file format reflects everything possible in the application, but I recommend you ask in the Open XML SDK forum where you'll find the specialists.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Amy Li Monday, November 29, 2010 2:45 AM
    Wednesday, November 24, 2010 5:16 PM