Reputation: 31
I have few objects embedded in a hidden sheet in workbook which runs the VBA code. These objects (word, excel, pdf etc.) are just the templates and I need to open a copy of these or open these as read only upon a click on a command button, so that the template content remains same.
I have searched over the internet but did not find a way to open these embedded objects as read only. I am running this code but save as operation is not successful.
Private Sub M114_Click()
Dim WDObj As Object
Dim WDApp As Object
Set WDApp = GetObject(, "Word.Application")
Set WDObj = Sheets("Tools").OLEObjects("MO")
WDObj.Activate
WDApp.ActiveDocument.SaveAs ("MO_copy.doc")
Set WDObj = Nothing
Set WDApp = Nothing
End Sub
Upvotes: 2
Views: 2109
Reputation: 21639
You need to protect the document to prevent changes before you embed it in Excel.
With the example of a Word Document:
You can use Word's protection functionality to protect it, and could optionally give different rights to different users.
Review
tab on the ribbon.Restrict Editing
**No Changes (Read Only)**
.Alternatively, if your embedded object is linked to the source file, you can set the file to Read Only in the Windows file properties. This won't work if the object isn't linked to the file.
Upvotes: 1