ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Picture in Worksheet Question (https://www.excelbanter.com/excel-programming/297311-insert-picture-worksheet-question.html)

Adresmith

Insert Picture in Worksheet Question
 
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

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


DNF Karran[_4_]

Insert Picture in Worksheet Question
 
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


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


Adresmith[_2_]

Insert Picture in Worksheet Question
 
Thank you! Works perfectly! I really appreciate it

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



All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com