VB.NET - Lock a word document using vb net

Asked By Kevin Scott
11-May-06 04:16 PM
I am trying lock a word document using vb.net . Anyone know how to do this?

did you try macro builder  did you try macro builder

15-May-06 02:57 PM
Although I don't know the exact code this tip might be more helpful then the code to do it.  

Open your word document.  Go to macro builder and set the recorder to record your actions which should include protecting or locking the document.  

Then stop the recorder and go to the Macro sub menu and select the Edit code selection.  

You will now see all the code you need.  If you don't see it right away keep opening and closing the project view on the left side till you see it.  If you need to open the word object tell me but I am assuming you know how to do that.  

Here is the code I got from building a macro
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/15/2006 by '
    ActiveDocument.TrackRevisions = Not ActiveDocument.TrackRevisions
    Selection.TypeText Text:="adfadfasdf"
    ActiveDocument.Protect Password:="1234", NoReset:=False, Type:= _
        wdAllowOnlyRevisions

Good Luck

found it myself a week later  found it myself a week later

18-May-06 02:06 PM
Dim bWord As New Word.Application
                bWord.Documents.Open(careGiverOutputPath + dt.Rows(counter)(0) + ".doc")
                bWord.ActiveDocument.Protect(Word.WdProtectionType.wdAllowOnlyFormFields)
                bWord.ActiveDocument.Save()
                bWord.Quit()
  jason rle replied to Kevin Scott
06-Aug-10 12:07 AM
Easiest way to lock a word document using a http://www.e-iceblue.com/Introduce/word-for-net-introduce.html component , I use it long time, name Spire.Doc, may help to you.
Create New Account
help
Accessing built-in constants in vb net - word app I wrote a VB.net app that creates a Word document from a text file and then saves it and quits. Everything works fine except power of .net and you have to hard code these things. The prob is a Word macro uses them all over the place, do you know what Word library to reference? Create
Word Document saving vb.net .NET Framework Hi Guys, I have an application written in vb.net that creates and saves a word document. We have just upgraded our office package from 2003 to 2007. Consequently our members format. Is there anyway I can programmatically save the document in 2003 format in my vb.net application? Some code follows:- ' prepare word document for printing Dim wrdSelection As Word.Selection Dim
Word and VB net question I am a TOTAL vb.net noob! (ok got that out of the way). I am writing a program that will read the contents (text only) of a word document into an array of strings so that I can extract data. The only catch Is there a simple way to look at the check box value of a MS Word file in vb.net? I will kiss the feet of whoever can help me with this!!! :) Thanks in
Hide Gridlines Word Using vb.net, how do you programmatically hide / show the gridlines of a table in a word document? The table and the document were also created via vb.net. Thanks Bob - - Message posted via OfficeKB.com http: / / www.officekb.com / Uwe / Forums.aspx word-programming / 200902 / 1 Word Programming Discussions ActiveWindow.View.TableGridlines (1) WordBasic.ShowTableGridlines (1) TriedoWord.WordBasic.ShowTableGridlines (1) Microsoft Word