Quantcast
Channel: Word for Developers forum
Viewing all articles
Browse latest Browse all 4350

how to make documents .docx to be readOnly in visual studio using Rich TextBox?

$
0
0

here is the code, when i run it the document can be seen in the rich textbox but it is editable  so I want it to be readonly document?

void ImportWord()
        {
            Microsoft.Office.Interop.Word.Application wordObject = new Microsoft.Office.Interop.Word.Application();
            object File = @"C:\Users\czu_ecu\Desktop\OAG-WORK\Management_Letter_Template1.docx" ; //this is the path
            object nullobject = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application wordobject = new Microsoft.Office.Interop.Word.Application();
            wordobject.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; Microsoft.Office.Interop.Word._Document docs = wordObject.Documents.Open(ref File, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject); docs.ActiveWindow.Selection.WholeStory();
            docs.ActiveWindow.Selection.Copy();
            this.richTextBox2.Paste();
            docs.Close(ref nullobject, ref nullobject, ref nullobject);
            wordobject.Quit(ref nullobject,ref nullobject, ref nullobject);


            

        }


        private void btnTemML_Click(object sender, EventArgs e) //Handles the actions of the template button
        {
                btnAdd_Finding.Visible = false;
                listView2.Visible = false;
                label8.Visible = false;
                richTextBox1.Visible = false;
                listView1.Visible = false;
                listView3.Visible = false;
                richTextBox2.Visible = true;
                

               

               
            ImportWord();

              




                  listView1.Items.Clear();

        }
    


                                                                                

Viewing all articles
Browse latest Browse all 4350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>