Insert Picture in Worksheet Question

A

Adresmith

I have no idea what I am doing and I am in a jam. If anyone can help m
I would be so appreciative!

I am trying to create a user form that will do the following:

1. Allow user to click button to upload picture from a file
2. Make the size of the picture 100 x 87 pixels
3. Have the picture be in cell J13
4. Protect the worksheet and the picture once inserted.
5. Let the user have the option of adding another picture on a ne
worksheet or saving and exiting workbook.

I am very new at using VBA and I am completely stuck all I have so fa
is a form called UploadForm with a button called UploadPhotoButton an
this code:

Private Sub UploadPhotoButton_Click()

Dim bRtn As Boolean

bRtn = Application.Dialogs(xlDialogInsertPicture).Show


If bRtn = False Then Exit Sub

Selection.ShapeRange.Height = 100
Selection.ShapeRange.Width = 87

End Su
 
D

DNF Karran

Option Explicit
Sub UploadPhotoButton_Click()

Dim bRtn As Boolean

LineStart:

Range("J13").Select 'If J13 is active, the image will be imported
here.

bRtn = Application.Dialogs(xlDialogInsertPicture).Show


If bRtn = False Then Exit Sub

Selection.ShapeRange.Height = 100
Selection.ShapeRange.Width = 87

ActiveSheet.Protect 'password can be added as well

If MsgBox("Do you want to import another?", vbOKCancel) = vbOK Then
Application.Worksheets.Add
GoTo LineStart
End If

ActiveWorkbook.Close Savechanges:=True,
Filename:=Application.Dialogs(xlDialogSaveAs).Show

End Sub
 
Top