ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Almost got it Bob- Active Shhet.Picture problem (https://www.excelbanter.com/excel-programming/299192-almost-got-bob-active-shhet-picture-problem.html)

Richard1284[_2_]

Almost got it Bob- Active Shhet.Picture problem
 
Hi all,

Thanks for your help so far however I am still stumped.
I have 4 cmdButtons, As each one is clicked I want a new picture t
come up(this is ok) HOWEVER i also want to delete the old pictur
already on the sheet(this is my problem). I have declared some global
and have tried to store the active sheet Picture in a cell, Have a loo
at my code....it is almost there but not quite, any ideas on how t
improve this.....

---------------------------------------------------
Public myPic As Picture '
Public sPic As String

Sub InsertPic1()
sPic = Sheets("Main").Cells(100, 6).Value

If sPic < "" Then
Set myPic = ActiveSheet.Pictures(sPic)
myPic.Delete
End If

sPic = ("F:\Dss\ass\Arran1.jpg")
Sheets("Main").Select
Range("D16").Select
Set myPic = ActiveSheet.Pictures.Insert(sPic)
Sheets("Main").Cells(100, 6).Value = sPi

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


Bob Phillips[_6_]

Almost got it Bob- Active Shhet.Picture problem
 
Richard,

How about another approach?

What you could do is to load all of the pictures up front, and [park them
off-view. Each command button would move
back to the park, and then bring in the required one.

Dim sh As Shape

Fr Each sh In ActiveSheet.Shapes
'first make sure all parked
sh.Left = 5000
Next sh

With ActiveSheet.Shapes("picCB1")
.Left = 100
.Top = 100
End With

and similar code for each CB.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Richard1284 " wrote in message
...
Hi all,

Thanks for your help so far however I am still stumped.
I have 4 cmdButtons, As each one is clicked I want a new picture to
come up(this is ok) HOWEVER i also want to delete the old picture
already on the sheet(this is my problem). I have declared some globals
and have tried to store the active sheet Picture in a cell, Have a look
at my code....it is almost there but not quite, any ideas on how to
improve this.....

---------------------------------------------------
Public myPic As Picture '
Public sPic As String

Sub InsertPic1()
sPic = Sheets("Main").Cells(100, 6).Value

If sPic < "" Then
Set myPic = ActiveSheet.Pictures(sPic)
myPic.Delete
End If

sPic = ("F:\Dss\ass\Arran1.jpg")
Sheets("Main").Select
Range("D16").Select
Set myPic = ActiveSheet.Pictures.Insert(sPic)
Sheets("Main").Cells(100, 6).Value = sPic


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




Tushar Mehta

Almost got it Bob- Active Shhet.Picture problem
 
See the response to the other discussion on the same subject in the
same newsgroup.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , Richard1284
says...
Hi all,

Thanks for your help so far however I am still stumped.
I have 4 cmdButtons, As each one is clicked I want a new picture to
come up(this is ok) HOWEVER i also want to delete the old picture
already on the sheet(this is my problem). I have declared some globals
and have tried to store the active sheet Picture in a cell, Have a look
at my code....it is almost there but not quite, any ideas on how to
improve this.....

---------------------------------------------------
Public myPic As Picture '
Public sPic As String

Sub InsertPic1()
sPic = Sheets("Main").Cells(100, 6).Value

If sPic < "" Then
Set myPic = ActiveSheet.Pictures(sPic)
myPic.Delete
End If

sPic = ("F:\Dss\ass\Arran1.jpg")
Sheets("Main").Select
Range("D16").Select
Set myPic = ActiveSheet.Pictures.Insert(sPic)
Sheets("Main").Cells(100, 6).Value = sPic


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




All times are GMT +1. The time now is 03:48 PM.

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