.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Opening New Word Document with Template Selection in C#

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :Windows Application
From a Windows Forms Application, I need to launch Word. There is an option to create a new document template in the Application. So to implement this, I need to launch the template selection window (You get it when you click File->New in 2007). Once the user selects the template, a new document is created with the selected template. How do I achieve this using Word Object Model?

View Complete Post

More Related Resource Links

InfoPath / ActiveX error when using person selector field in Word template off SharePoint document l

I have created an out-of-the-box document library on a SharePoint 2010 site.  I left Microsoft Word Document selected as the Document Template.  I then added a person or group column and a multiple lines of text column to the document library. I then went into Library Settings --> Advanced Settings and clicked on Edit Template, opening the template in Word.  I created my template and added the two new columns to the document.  I did this using the Quick Parts --> Document Property --> [column name] feature under the Insert tab in Word.  I then saved the template back to SharePoint. Upon opening the template or creating a new document from the template, I get the following dialog box: --------------------------- Microsoft Office InfoPath --------------------------- One or more ActiveX controls could not be displayed because either: 1) Your current security settings prohibit running ActiveX controls on this page, or 2) You have blocked a publisher of one of the controls. As a result, the page might not display correctly. --------------------------- OK   --------------------------- I've searched around (I believe fairly extensively) and have not run into anyone else with the same issue.  Some have mentioned a similar error when creating a custom document information panel in InfoPath, and suggested lowered ActiveX security setti

Opening Word 2003 document from sharepoint site in word 2010.


When using sharepoint services with word 2003 on an XP machine, everything works fine. We bought some new computers where we now have windows 7 and office 2007/2010. These work perfect too. Even the 64-bit computers.

We are very happy with the new office version, so we decided to upgrade the entire company. As a test, we upgraded 1 PC. But this is not working. So we upgraded office, later we reinstalled it. But nothing helps. This is the problem: I surf to the document click it to open it, and then Word hangs. "contacting server". This is not always the case, sometimes it works, sometimes it doesn't. This even with the same document.

We would really like to upgrade to office 2010 entirely. But we're not going to buy licences we cannot use. Anybody got a solution?

Word Web App cannot open this document due to an unknown error. If the problem persists, try opening

Word Web App cannot open this document due to an unknown error. If the problem persists, try opening the file in Microsoft Word.

Can anybody pls help me how to resolve this for which got strucked !!!!


Cheers !!


Thanks in Advance !!! Cheers !!! Praveen

Word Web App cannot open this document due to an unknown error. If the problem persists, try opening


Word Web App cannot open this document due to an unknown error. If the problem persists, try opening the file in Microsoft Word.

Hii ,

Can anybody pls help me how to resolve the above Error am getting in Sharepoint Foundation with the use Office WebApps installed on the same development server,when Opening a word document after it got created.






Thanks in Advance !!! Cheers !!! Praveen Mandalapu

External Data Fields in a Word Template saved as a content type in a document library with multiple


I have created a Word Template for a Document Library that has an External Data Column in it of Client Name which also adds Client Address1, Client Address2, Client City, Client State, & Client Zip.  Now this works fine for a Document library with that template as the Template.dotx file. 

I want to be able to make a bunch of Templates and have them all as Content Types in one Library.  When I do this I cannot get the External Data Quick Parts to work.

Anyone have any ideas?

Sign-on prompts while opening Word doc. from Sharepoint (due to template)


Some of our users are getting a lot of sign-on prompts while opening documents from Sharepoint.

After some troubleshooting I noticed that the prompt popped up while Office was trying to load the Template of the document, the problem was that the document was created with a template from a site to which the user didn't have access.

You can check this by opening the document, pressing cancel a few times until the document opens, go to the "Developer" tab in the ribbon, press the "Document Template" and check out the path of the template being used. You could fill out the correct template here or clear it and your problem will be fixed.

Steps to recreate:

  • Create a document from a custom Word template in a document library.
  • Move document to other document library.
  • Remove your read/write rights from the first document library.
  • Try to open the document from the second document library, here you'll get the sign-on prompts.
  • Be sure to check that your not using a admin account.

I'm hoping someone can give me another way to fix this, because changing all the document Template settings is a tedious job.

Erwin Bastiaensen (sharepointology.com) Dont forget to click "Mark as Answer" on the post that helped you.

Passing Calculated Columns from Sharepoint into Word Document Library Template


Hi all...

Another noob question.  I have been able to figure out how to pass single line text, date, etc. data from a Sharepoint List into a Word Template, but I am still trying to figure out how to pass a calculated column.  Is there a workaround?


Charset Problem with dynamically generated Word Document


in my asp.net web application i am dynamically generating a word documnet out of a sql data. I have set the char set UTF-8 during the doument creation in code but still when i open the generated document and check it char set .. it is always windows-1252 not the one that i have set. My sql data in the document have special characters whihc can only be understandable using the UTF-8 charset otherwise its always ?T written in place of an apostrophy . Pasting my code here..

         HttpContext.Current.Response.ContentType = "application/msword";
         HttpContext.Current.Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8;
         HttpContext.Current.Response.Charset = "utf-8";
         string strFileName = "Details" + ".doc";
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
        StringBuilder strHTMLContent = new StringBuilder();
        string strMessage = " ";
        DataView abstractview = (DataView)dsAbstract.Select(DataSourceSelectArguments.Empty);
        foreach (DataRowView row1 in abstractview)
            strMessage += "<table border='1' cellspacing='0' cellpadding='5' width

Embed word document inside excel



I am using ASP.NET and C# 2.0 and working on web application.

I want to embed a word document inside a excel sheet.

How to embed word document inside excel.

Thank you



Advanced Basics: Setting Word Document Properties the Office 2007 Way


The last time I wrote this column (March 2006), I shared an application that allows you to update all the Microsoft® Word documents in a folder and its subfolders. Each time the application finds a document in the specified path, it updates the document properties to match those you specified in the application.

Ken Getz

MSDN Magazine June 2006

Advanced Basics: Set Word Document Properties Programmatically


At the beginning of another lovely day of writing courseware in mad pursuit of unrealistic deadlines, I received a frantic call from a business partner. He was at the end of a long consulting project and had several hundred Microsoft® Word documents, all of which required their document properties to be set identically, except the Title property of the document, which was to be based on the document file name, minus the .

Ken Getz

MSDN Magazine March 2006

Full text search in a Word document



  I´m currently programming a web search application in ASP.Net and having problem with full text searching. My requirements are:

1. Save a byte array from SQL server to word document as a temp file in a server side?

2. How to highlight the string I am currently searching in the Word document and return to the user the sentence with the highlighted string (like on Bing or any other search engines)? Is it possible to fullfill this requirement with full-text search integrated in SQL Server 2008?

Thanks in advance,




Re-authentication issue when openeing a MS Word Document


We have a SharePoint installation for one of our clients with external access enabled using https via ISA server. When accessing the portal internally within the intranet/domain its fine. In case of external access using https when users login to portal adn when they try to open a MS Word (or any Office) document they are prompted to to enter their username and password again. It happens for every MS Office document. We are using MOSS 2007, Office 2007. I know that the promp for re-authentication is is due to the fact that office try to open a new session but is there any work around to overcome this.

Any help will be highly appreciated.



Search does not find text in Word document stored in document library on a Report Center site within



We have a document library on a site created off of the Report Center site template. We uploaded a Word 2007 document with the word zebra in the text. Using the search bar at the top of the page we selected This list: Our document library and searched for zebra. We received no results.

We tested the same thing on another site (site template Team site) within the same site collection and search worked fine.

Does the Report Center search function differently then the search functionality on the Team site?

Tamara Bredemus SharePoint Minion...working up to Maven

Check-out issue when opening a document from a document library when a read-only copy is open

We have an issue when a user has a read-only copy of a document from SharePoint open and then tries to check-out and edit another copy of the document (i.e. from the document library) the checked out copy is not connected to the web server. For the user it will look the same they will make edits, save and then close, but when they do so the document is not updated in SharePoint - it may be saved locally in their SP drafts, but the user will think that they have lost their version. We then get the checked out to another user error and you have to discard changes to get the document working again. Steps to reproduce this issue: * click on the name of a office doc on a Document Library * Make sure "Read Only" is selected and click "ok" * Minimize open document * click on the same file on the Document Library * Make sure "check out and edit" is selected and the "Use my local drafts folder" checkbox is ticked. Select OK. * Edit document and press save. Changes are never saved back in SharePoint, they are only on the local draft. We are using MOSS with SP2. Clients are on Office 2003 and 2007 Is this normal behaviour? Is there anything that can be done to prevent this from happening?

Replace text in a word document stored in a Document Library


Hi to all,

im tying to replace some text introduced in a word document stored in a document library.

Exactly i need a web part with a button that change a key in a word template <list> (for example) and replace <list> with a text in another list.


I think that it would works with the Microsoft.Office.Word.Interop; namespace but when i call the function :

wDoc = wordApp.Documents.Open(ref fileName, ref missing,
                                ref readOnly, ref missing, ref missing, ref missing,
                                ref missing, ref missing, ref missing, ref missing,
                                ref missing, ref isVisible, ref missing, ref missing,

merge word document



I recently created a team site on the SharePoint for projects management and our team will use the word document for inserting the information about the project that they work on it,

My case is:

for each project have multiple documents and i created a user control by VS.2005, this user control contain a drop down list contain all projects and merge button, when the user choose any project and click merge i will use the Work dll to merge all document that related to the project and export to the user.

This is my code

private void mergeDocument()


ApplicationClass WordApp =

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend