ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help please- user selectable image (https://www.excelbanter.com/excel-programming/295816-help-please-user-selectable-image.html)

Regnar

Help please- user selectable image
 
I posted a message and everyone bypassed it. I know I ask
for a lot, but I am stuck. If you can't help, can you
direct me to someone who can? please.

I have a workbook that I need to have a image imported
from a users local machine. The workbook is protected,
but I would like them to be able to click(or double) a
sized cell and have a .jpg photo from their machine fit
to size in the box keeping aspect ratio of the image, and
making the background of the unused cell(or imagebox
whichever is better) white. The image has to be able to
print, and the sheet has to remain protected. I want to
save this as a template, that has no image in the box
when opened. Any more information needed to help get an
answer, I will provide.

Regnar



Vasant Nanavati

Help please- user selectable image
 
Probably far from foolproof, but this should get you started. You can either
unprotect and reprotect the worksheet by providing the password in your
code, or set the protection to UserInterfaceOnly which will allow macros to
work:

Sub InsertAndSize()
Dim c As Range, AR As Double
Set c = ActiveCell
ActiveSheet.Unprotect "MyPassword"
If Application.Dialogs(xlDialogInsertPicture).Show = False Then
Exit Sub
Else
With Selection
AR = .Height / .Width
.Top = c.Top
.Left = c.Left
If c.Height / c.Width = AR Then
.Width = c.Width
.Height = .Width * AR
.Left = c.Left
.Top = c.Top + (c.Height - .Height) / 2
Else
.Height = c.Height
.Width = .Height / AR
.Top = c.Top
.Left = c.Left + (c.Width - .Width) / 2
End If
End With
End If
ActiveCell.Select
ActiveSheet.Protect "MyPassword"
End Sub

Note that the correct cell will need to be selected. Otherwise, you can
explicitly define the cell in which you want the picture contained.

--

Vasant





"Regnar" wrote in message
...
I posted a message and everyone bypassed it. I know I ask
for a lot, but I am stuck. If you can't help, can you
direct me to someone who can? please.

I have a workbook that I need to have a image imported
from a users local machine. The workbook is protected,
but I would like them to be able to click(or double) a
sized cell and have a .jpg photo from their machine fit
to size in the box keeping aspect ratio of the image, and
making the background of the unused cell(or imagebox
whichever is better) white. The image has to be able to
print, and the sheet has to remain protected. I want to
save this as a template, that has no image in the box
when opened. Any more information needed to help get an
answer, I will provide.

Regnar






All times are GMT +1. The time now is 05:47 PM.

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