Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 277
Default putting a picture onto a userform without using the vba window

On Sun, 29 Nov 2009 08:16:02 -0800, Roger on Excel
wrote:


A question I have is how does one make it so that it so that the picture
stays on the form when I reopen it? When I close and reopen the form, the
picture disappears.


I have an image "pop" code snippet that places an image up *after*
deleting the current image. The difference being that the image remains.

caveat: ONLY if you perform a save of the workbook.

This is a modified piece of code I got here, from another author.

You would have to decide where to plug it into your code and modify the
target cell range in "pop". It will auto-size the images to fit whatever
"box" you set up.

There are two routines:

Sub Pop()
On Error Resume Next
ActiveSheet.Shapes("Popped").Delete
InsertPicture Range("H7").Value, _
Range("H7:I22"), "Popped"
End Sub


Sub InsertPicture(PictureFileName As String, TargetCells As Range,
picName As String)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If TypeName(ActiveSheet) < "Worksheet" Then Exit Sub
If Dir(PictureFileName) = "" Then Exit Sub
' import picture
Set p = ActiveSheet.Pictures.Insert(PictureFileName)
'Name the picture so you can delete it later....
p.Name = picName
' determine positions
With TargetCells
t = .Top
l = .Left
w = .Offset(0, .Columns.Count).Left - .Left
h = .Offset(.Rows.Count, 0).Top - .Top
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting a picture behind text in Excel 2007 evans t Excel Discussion (Misc queries) 6 March 26th 10 05:54 PM
Chart Picture Size in UserForm/Picture Control. Dan Excel Programming 8 May 30th 08 08:04 PM
Duplicated code window and userform window problem Zhu Excel Programming 3 November 8th 06 05:09 AM
putting validation to TextBox in the userform salihyil[_6_] Excel Programming 1 February 26th 04 12:10 PM
putting validation to TextBox in the userform salihyil[_8_] Excel Programming 1 February 26th 04 10:59 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"