primaryteach
01-13-2010, 09:08 AM
Hi everyone,
I have this piece of code that inserts an embedded file to a worksheet. This works well. However, I wish to use this on a protected sheet where other users can access the attached file but by default an inserted object is 'locked'. How can I change the code so that the inserted file (vFile) is changed to being 'unlocked' to allow access to it?
Thanks in advance,
Simon
Private Sub CommandButton1_Click()
Dim vFile As Variant
ActiveSheet.Unprotect "pass"
Range("F26").Select
vFile = Application.GetOpenFilename("All Files,*.*", Title:=" Find file to insert")
If LCase(vFile) = "false" Then Exit Sub
ActiveSheet.OLEObjects.Add Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconLabel:=vFile
ActiveSheet.Protect "pass", _
Contents:=True, _
UserInterfaceOnly:=True
ActiveSheet.EnableAutoFilter = True
ActiveSheet.EnableOutlining = True
End Sub
I have this piece of code that inserts an embedded file to a worksheet. This works well. However, I wish to use this on a protected sheet where other users can access the attached file but by default an inserted object is 'locked'. How can I change the code so that the inserted file (vFile) is changed to being 'unlocked' to allow access to it?
Thanks in advance,
Simon
Private Sub CommandButton1_Click()
Dim vFile As Variant
ActiveSheet.Unprotect "pass"
Range("F26").Select
vFile = Application.GetOpenFilename("All Files,*.*", Title:=" Find file to insert")
If LCase(vFile) = "false" Then Exit Sub
ActiveSheet.OLEObjects.Add Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconLabel:=vFile
ActiveSheet.Protect "pass", _
Contents:=True, _
UserInterfaceOnly:=True
ActiveSheet.EnableAutoFilter = True
ActiveSheet.EnableOutlining = True
End Sub