Other usages with the Word Object Model

John 506 Reputation points
2023-02-20T07:14:34.8466667+00:00

I would like to know more about usages with the Word Object Model.

Previously, I have added a comment to a related previous post that users may not use the Word Object Model with just a Rich Text Box.

I am on a different topic now.

Would I need to add a control such as a Text Edit WPF control?

Or would I need to simply add another control just to use the Word Object Model such as a Rich Text Box or Text Box?

Right now, I am doing my best to instantiate those classes properly.

It has not turned out the way I have wanted to since my last posted code snippet.

Maybe I might be missing some assembly references.

Here is a code snippet:

using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Word;
using System;
using System.Windows.Forms;

Would I also need a Flow Document class and instantiate it?

Besides using the Word Object Model may require either a Rich Text or Text Box control just to access its methods and properties, such as Application or Selection classes without the need for going to a different project type.

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Word | For business | Windows
Developer technologies | C#
{count} votes

Accepted answer
  1. Jack J Jun 25,296 Reputation points
    2023-02-20T09:18:45.4233333+00:00

    @John, Welcome to Microsoft Q&A, you could try the following code to use c# code to achieve the same function with the VBA code:

    using Word = Microsoft.Office.Interop.Word;
    
                Word.Application app = new Word.Application();  
                app.Visible=true;
                app.Documents.Open("C:
                app = null;
    
    

    Best Regards,

    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.