Click here to Skip to main content
15,894,955 members
Home / Discussions / Web Development
   

Web Development

 
QuestionGenerate word document from web form Pin
Hemant Thaker18-Jun-09 23:12
Hemant Thaker18-Jun-09 23:12 
AnswerRe: Generate word document from web form Pin
Not Active19-Jun-09 2:44
mentorNot Active19-Jun-09 2:44 
GeneralRe: Generate word document from web form Pin
Hemant Thaker19-Jun-09 4:37
Hemant Thaker19-Jun-09 4:37 
GeneralRe: Generate word document from web form Pin
Not Active19-Jun-09 5:08
mentorNot Active19-Jun-09 5:08 
QuestionRe: Generate word document from web form Pin
led mike19-Jun-09 5:18
led mike19-Jun-09 5:18 
QuestionRe: Generate word document from web form Pin
Hemant Thaker19-Jun-09 23:17
Hemant Thaker19-Jun-09 23:17 
AnswerRe: Generate word document from web form Pin
Not Active20-Jun-09 4:07
mentorNot Active20-Jun-09 4:07 
AnswerRe: Generate word document from web form [modified] Pin
Gary Stafford21-Jun-09 8:38
Gary Stafford21-Jun-09 8:38 
Your code worked fine for me without modification. I added your code to an existing project in Visual Studio 2008. I added a COM reference to the Microsoft Word 11.0 Object Library and kept your using directive for the Microsoft.Office.Interop.Word namepsace. I then placed your code into the CreateWordDoc() method, within the WordDoc class. When I then called the method, It created the Word file without any error.

using Microsoft.Office.Interop.Word;

public class WordDoc
{
    public void CreateWordDoc()
    {
        ApplicationClass oWordApp = new ApplicationClass();
        object fileName = "c:\\myfile.doc";

        object missing = System.Reflection.Missing.Value;
        Document oWordDoc = oWordApp.Documents.Add(ref missing,
        ref missing, ref missing, ref missing);

        oWordDoc.Activate();

        oWordApp.Selection.TypeText("This is the text");
        oWordApp.Selection.TypeParagraph();
        oWordDoc.SaveAs(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

        oWordApp.Application.Quit(ref missing, ref missing, ref missing);
    }
}


Regards,

Gary

modified on Sunday, June 21, 2009 2:45 PM

QuestionRe: Generate word document from web form Pin
Hemant Thaker21-Jun-09 23:41
Hemant Thaker21-Jun-09 23:41 
QuestionRe: Create Header in word document dynamically Pin
Hemant Thaker23-Jun-09 3:30
Hemant Thaker23-Jun-09 3:30 
AnswerRe: Create Header in word document dynamically Pin
Gary Stafford23-Jun-09 12:56
Gary Stafford23-Jun-09 12:56 
GeneralRe: Create Header in word document dynamically Pin
Hemant Thaker26-Jun-09 23:55
Hemant Thaker26-Jun-09 23:55 
QuestionData Scrapping in Asp.net Pin
ravi.vellanky18-Jun-09 21:12
ravi.vellanky18-Jun-09 21:12 
AnswerRe: Data Scrapping in Asp.net Pin
Not Active19-Jun-09 2:41
mentorNot Active19-Jun-09 2:41 
QuestionJquery Validation plugin in Ajax Update Panel Pin
sagnik mukherjee18-Jun-09 8:41
sagnik mukherjee18-Jun-09 8:41 
QuestionSourceCode for Sharing My Website on Social Networking Sites Pin
mshen0118-Jun-09 4:44
mshen0118-Jun-09 4:44 
AnswerRe: SourceCode for Sharing My Website on Social Networking Sites Pin
Aman Bhullar18-Jun-09 19:44
Aman Bhullar18-Jun-09 19:44 
QuestionUse same objects to access DB and WebService Pin
the_jat18-Jun-09 3:55
the_jat18-Jun-09 3:55 
AnswerCross Posted Pin
led mike18-Jun-09 4:46
led mike18-Jun-09 4:46 
GeneralRe: Cross Posted Pin
the_jat18-Jun-09 4:53
the_jat18-Jun-09 4:53 
GeneralRe: Cross Posted Pin
led mike18-Jun-09 5:17
led mike18-Jun-09 5:17 
GeneralRe: Cross Posted Pin
the_jat18-Jun-09 19:04
the_jat18-Jun-09 19:04 
GeneralRe: Cross Posted Pin
led mike19-Jun-09 5:19
led mike19-Jun-09 5:19 
QuestionIs ActiveX old technology these days? Pin
TheIdleProgrammer18-Jun-09 0:26
TheIdleProgrammer18-Jun-09 0:26 
AnswerRe: Is ActiveX old technology these days? Pin
led mike18-Jun-09 4:49
led mike18-Jun-09 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.