working with a protected sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how can i import graphics/pictures once a sheet is protected? i successfully protected and unprotected areas to be accessable and unaccessable respectively. but now that i protected the sheet, i am not allowed to import graphics into the unprotected area (or the protected area for that matter), which is a vital purpose of the template which i am attemptiing to create. can anyone help me?
 
I think the only way is to add the picture
programmatically. The following macro can be assigned to
a command button or such.

My code assumes you want the user to select the picture
from a file. Note that the "Filt" variable is a string
that receives the file extension types used as a filter
for the GetOpenFileName method. The required syntax is a
little confusing. This is optional but limits the file
types to picture files when browsing for the photo. Not
all picture file types are listed - you may require more
in the list but I doubt it.

The code is designed to size the picture to the dimentions
of the active cell and paste it to the active cell. It
can of course be redesigned to do whatever you want in
this regard. Before running the code, first size a cell
to the desired photo size and select the cell.

Sub InsertPict()
Dim PictName As String, Filt As String
Dim L As Single, T As Single, W As Single, H As Single
'Specify picture file types as filter
Filt = "(*.emf; *.wmf; *.jpg; *.jpeg; *.jfif; *.jpe; " & _
"*.png; *.bmp), *.emf; *.wmf; *.jpg; *.jpeg; *.jfif;
*.jpe; " & _
"*.png; *.bmp"

'Call Open dialog and pass selection path to PictName
PictName = Application.GetOpenFilename(FileFilter:=Filt)
'Pass activecell parameters to variables
With ActiveCell
L = .Left: T = .Top: W = .Width: H = .Height
End With
'Unprotect sheet and add selected picture then reprotect
With ActiveSheet
.Unprotect "monkey"
.Shapes.AddPicture PictName, True, True, L, T, W, H
.Protect "monkey"
End With
End Sub

Hope it works.

Regards,
Greg

-----Original Message-----
how can i import graphics/pictures once a sheet is
protected? i successfully protected and unprotected areas
to be accessable and unaccessable respectively. but now
that i protected the sheet, i am not allowed to import
graphics into the unprotected area (or the protected area
for that matter), which is a vital purpose of the template
which i am attemptiing to create. can anyone help me?
 
Back
Top