Hi ?B?UmVkIE1hZ2U=?=,
This should better be discussed in a macro group, such as word.vba.general,
however...
You cannot programmatically change the content of the VBA project if it is
"locked for viewing" (protected).
Perhaps if you explain (in the macro newsgroup) why you would need to copy and
delete modules one could think of an alternate approach...
I locked MySample template Project using
Tools - Template Project Properties - Protection tab -under Lock project
group i checked the checkbox (Lock for viewing) and also the password
"mypassword" in the password fields.This way i protected the document.
Now MySample template is protected,but i need to delete a module from this
template and i have to copy a module from other template using VBA. Im able
to delete the module but im not able to copy the module....
If the MySample template is not protected with Password the following code
works....othewise it fails
Sub MacroCopy
Dim MacroName, fromfile, tofile As String
MacroName = "TestMacro"
fromfile = "C:\MacroCopy.dot"
tofile = "C:\MySample.dot"
Documents.Open FileName:=tofile, Visible:=True
Documents(tofile).Activate
'Remove the existing Module from the template
On Error Resume Next
Application.OrganizerDelete Source:=tofile, Name:=MacroName, _
Object:=wdOrganizerObjectProjectItems
'Copy the macro to the template
Application.OrganizerCopy Source:=fromfile, Destination:=tofile _
, Name:="InspectionInfo", Object:=wdOrganizerObjectProjectItems
Documents.Save NoPrompt:=True, OriginalFormat:=wdOriginalDocumentFormat
ActiveDocument.ActiveWindow.Close
End Sub
what i have to do in the code so it can copy the module,eventhough it id
protected for viewing...
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)