Active1 year, 4 months ago
I'm using WinForms. Free online solidworks training courses. I have a form that has a button.
Free Word Application For Windows
Oct 05, 2018 winword.exe is the executable file name for Microsoft Word which is used when Word is launched. The word WinWord stands for Windows Word (Microsoft Word). This software component is also used by other applications such as Outlook when attachments are to be viewed either in Outlook or in another window in Word. Word document: word.doc One Two three C# program that uses Microsoft Word interop using System; using Microsoft.Office.Interop.Word; class Program static void Main // Open a doc file. Application application = new Application; Document document = application.Documents.Open('C:word.doc'); // Loop through all words in the document.
Goal: On button click: Open up a word document. Lotro free turbine points. Where the file path is hard coded into the program. I don't want the users to have to locate the word document.
Problem: I receive this error message. When I wrote my code, I get a red error line under 'Application'.
taji01taji0168011 gold badge1818 silver badges4949 bronze badges
3 Answers
first add the dll of
Microsoft.Office.Interop.Word
to your references then add this:and use the following code:
atoMerz3,8391414 gold badges4848 silver badges9191 bronze badges
amit dayamaamit dayama2,80911 gold badge99 silver badges2828 bronze badges
Instead of adding interop in your reference, you may also consider to use this:
HeisenbergHeisenberg
This
So you can use this code:
Application
is not this.Application
it's Microsoft.Office.Interop.Word.Application
.So you can use this code:
Zhr SaghaieZhr Saghaie
Not the answer you're looking for? Browse other questions tagged c#.netwinformsfile or ask your own question.
-->Represents the Microsoft Word application. The Application object includes properties and methods that return top-level objects. For example, the ActiveDocument property returns a Document object.
Remarks
Use the Application property to return the Application object. The following example displays the user name for Word.
Many of the properties and methods that return the most common user-interface objects—such as the active document (ActiveDocument property)—can be used without the Application object qualifier. For example, instead of writing
Application.ActiveDocument.PrintOut
, you can write ActiveDocument.PrintOut
. Properties and methods that can be used without the Application object qualifier are considered 'global.' To view the global properties and methods in the Object Browser, click <globals>
at the top of the list in the Classes box. (Also see the Global object.)Remarks
To use Automation (formerly OLE Automation) to control Word from another application, use the Microsoft Visual Basic CreateObject or GetObject function to return a Word Application object. The following Microsoft Excel example starts Word (if it is not already running) and opens an existing document.
Events
Methods
Properties
See also
Support and feedback
C Word Application Download
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.