Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Putting a picture behind text in Excel 2007 | Excel Discussion (Misc queries) | |||
Chart Picture Size in UserForm/Picture Control. | Excel Programming | |||
Duplicated code window and userform window problem | Excel Programming | |||
putting validation to TextBox in the userform | Excel Programming | |||
putting validation to TextBox in the userform | Excel Programming |