Inserting a picture into a Userform from a stored location

C

Corey

I have used the following code (part of another procedure) to place a picture over a cell in a
sheet by the picture addres located on my PC.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Photo 1
Application.ScreenUpdating = False
If Range("C112").Value <> "" Then
Range("C97").Select
ActiveSheet.Unprotect
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim mypic As Picture
Dim res As Variant
Set WB = ActiveWorkbook
res = rngFound.Offset(0, 23).Value
If res = False Then Exit Sub
Set SH = ActiveSheet
Set rng = ActiveCell
Set mypic = SH.Pictures.Insert(res)
With mypic
.Top = rng.Top
.Left = rng.Left
.Locked = False
mypic.ShapeRange.LockAspectRatio = msoFalse
mypic.ShapeRange.Height = 213.1
mypic.ShapeRange.Width = 249.2
mypic.ShapeRange.Rotation = 0#
ActiveCell.Offset(1, 0).Value = res
End With
End If
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


But i am trying to do the same, but the picture to be displayed on a userform(Image1), but have not
been able to do so.
1). Is this possible?
2). How would it be coded?

Any assistance would be appreciated.

Regards


Corey....
 
C

Corey

Never mind

Got it sorted using the:
UserForm9.Image1.Picture = LoadPicture(PictureLocation)


Corey...


I have used the following code (part of another procedure) to place a picture over a cell in a
sheet by the picture addres located on my PC.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Photo 1
Application.ScreenUpdating = False
If Range("C112").Value <> "" Then
Range("C97").Select
ActiveSheet.Unprotect
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim mypic As Picture
Dim res As Variant
Set WB = ActiveWorkbook
res = rngFound.Offset(0, 23).Value
If res = False Then Exit Sub
Set SH = ActiveSheet
Set rng = ActiveCell
Set mypic = SH.Pictures.Insert(res)
With mypic
.Top = rng.Top
.Left = rng.Left
.Locked = False
mypic.ShapeRange.LockAspectRatio = msoFalse
mypic.ShapeRange.Height = 213.1
mypic.ShapeRange.Width = 249.2
mypic.ShapeRange.Rotation = 0#
ActiveCell.Offset(1, 0).Value = res
End With
End If
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


But i am trying to do the same, but the picture to be displayed on a userform(Image1), but have not
been able to do so.
1). Is this possible?
2). How would it be coded?

Any assistance would be appreciated.

Regards


Corey....
 
F

FSt1

hi
you really don't need code unless you plan to change the picture frequently.
forms have a picture property and you can set the property at design time as
background. and it is easy enough to change.
also there is an image control that can be dropped onto the form and display
images suchas logos or whatever.

have you tried to write code to display the pic. what are you plans for the
pic.

regards
FSt1
 
J

Jon Peltier

From the VBA help files:
_____
Picture Property

Specifies the bitmap to display on an object.


Syntax


object.Picture = LoadPicture( pathname )


where object is the image control, and pathname refers to the image file on
disk.
_____

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top