Group: microsoft.public.word.vba.general
From: =?Utf-8?B?RGVyZWsgUmVlZA==?=
Date: Tuesday, February 19, 2008 10:44 AM
Subject: RE: Locking Master Document

Thank you!

That is very helpful. I agree the it is a bit strange, but is a neat
solution for the application I am working on. It allows to to put fixed text
in the master document, and allow the users to edit the subdocuments

Cheers!

"Jean-Guy Marcil" wrote:

> "Derek Reed" wrote:
>
> > Thank for taking time to respond, but unfortunately it does not address my
> > question. What you have described is the mechanism for locking subdouments;
> > which I already know what to do.
> >
> > My question is how to lock the Master document. You can do it by moving the
> > cursor to a line in the master document and clicking the lock buttom on the
> > toolbar; I cannot however work out how to do the same from VBA.
>
> I do not think that button was intend for that purpose, but it does lock the
> master document itself while leaving the subdocuments unlocked, which is a
> bit weird, no?
>
> In any case, since this is what you need to do, I looked into it and the
> only way I managed to make this work with VBA is as follows. The code works
> as a toggle because if the master is locked, it will unlock it, and vice
> versa.
>
>
> Sub ToggleLockMaster()
>
> Dim cmdbarOutline As CommandBar
> Dim ctrOutline As CommandBarControl
> Dim i As Long
>
> If ActiveDocument.IsMasterDocument Then
> Selection.HomeKey wdStory
>
> If Not ActiveDocument.ReadOnly Then
> ActiveDocument.Save
> End If
>
> Set cmdbarOutline = Application.CommandBars("Outlining")
>
> For i = 1 To cmdbarOutline.Controls.Count
> Set ctrOutline = cmdbarOutline.Controls(i)
> If ctrOutline.ID = 236 Then ctrOutline.Execute
> Next
> Else
> MsgBox "The currently active document is not a master document.", _
> vbExclamation, "Cancelled"
> End If
>
> End Sub

Safety Articles | Usenet Groups | Usenet News | Bluegrass