locked
How to create word document file from html tags using vb.net RRS feed

  • Question

  • User2108435954 posted

    Hi all

    I have a html table in my page and i need when my user click in the word document generator button, create the word document of my html table and set page layout in margin = 0px and Orientaion = landscape and pagesize = A4

    if any of my friends in this forum can create document by this properties please help me.

    Best Regards.

    Saturday, November 6, 2010 4:02 AM

Answers

  • User1564875471 posted

    can i using microdoft.office.core and set my document properties exp. orientation and pagezise?

    Yes if you used Word.ApplicationCalss() , you will be able to change any document property that you see in word interface.For example,to change the orientation, you just use this code:

    YourApplicationObject.Selection.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 6, 2010 5:31 AM

All replies

  • User1564875471 posted

    The quickest and easiest way is to build the html table dynamically (using stringbuilder ) , and then write it to response stream and set the content type to "application/msword".This way doesn't gives you much flexibility in selecting pagesize and orientation.[article]

    The other way is to use office automation where you create an object of type word application and then start adding contents to it then save it.[article]

    Saturday, November 6, 2010 5:02 AM
  • User2108435954 posted

    Hi all-star

    Thanks for attention to my post.

    i now create my document of pages by using stringbuilder.

    new question...

    can i using microdoft.office.core and set my document properties exp. orientation and pagezise?

    i even install microsoft office in my dedicated server to use this application for create word document in vb.net

    Best Regards.

    Saturday, November 6, 2010 5:20 AM
  • User1564875471 posted

    can i using microdoft.office.core and set my document properties exp. orientation and pagezise?

    Yes if you used Word.ApplicationCalss() , you will be able to change any document property that you see in word interface.For example,to change the orientation, you just use this code:

    YourApplicationObject.Selection.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 6, 2010 5:31 AM
  • User2108435954 posted

    All-Star thank you very much for my tips.

    Please get a few minute to try your solution.

    Saturday, November 6, 2010 5:43 AM
  • User2108435954 posted

    Dear All-Star

    Your solution the best thank you very much.

    Sorry i have new question...

    i need to response outOfstream my document for download users and i do not want saveAs the document on my server befor downloaded users.

    i think no have a question

    Saturday, November 6, 2010 6:36 AM
  • User2108435954 posted

    New question.

    When i make document in office.core i just add text to document content but i want add html content in my document.

    if any of my friend know in this area please help me.

    Best Regards.

    Saturday, November 6, 2010 9:26 AM
  • User1564875471 posted

    To get better help, i suggest to ask your quesiton on this forum:

    http://social.msdn.microsoft.com/Forums/en/vsto/threads

    Saturday, November 6, 2010 9:31 AM
  • User2108435954 posted

    Hi All-Star

    I ask my question in that web site but i still waiting to get answer from that users site.

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2f368053-86a4-42f9-9295-6d7d53769d22/ 

    Saturday, November 6, 2010 9:40 AM