View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
TroyW[_2_] TroyW[_2_] is offline
external usenet poster
 
Posts: 94
Default Opening and closing a picture dialogue box

Try the code below. The code needs to go into the Sheet object code pane,
not a standard Module code pane. The example below assumes the name of the
button is: CommandButton1
Replace "mypassword" with the password for your sheet.

Troy


Private Sub CommandButton1_Click()
ActiveSheet.Unprotect Password:="mypassword"
Application.Dialogs(xlDialogInsertPicture).Show
ActiveSheet.Protect Password:="mypassword"
End Sub


"jontait " wrote in message
...
Hi all

I need some help (I'm not very good with VB):

I'd like to have a command button within my spreadsheet that when
clicked on opens up the INSERT PICTURE FROM FILE dialogue box, which
then allows a user to select a picture then click OK.

Sounds easy? Well the problem is that the spreadsheet is going to be
password protected. Therefore the command button needs to:

1. When clicked on automatically unprotect the spreadsheet (by secretly
inserting the password - i.e. without the users seeing what it is)
2. Open up the INSERT PICTURE FROM FILE dialogue box
3. Allow a user to find their pic and click OK (go to 4)
3a. If the user clicks cancel go to 4
4. Close the dialogue box and automatically re-protect the
spreadsheet.
5. Allow the user to re-size and drag the picture around to where they
want it.

Is this possible?? I really want the spreadsheet protected as there are
certain control boxes and nested IF's that I don't want the user to be
able to alter, but one of the key features is that they are to be able
to enter a picture into the sheet.

Thank you for all your help


---
Message posted from http://www.ExcelForum.com/