![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
I have a chart in a workbook that i want to make appear when you hit a command button, stay for 10 seconds and then disappear.
Any suggestions would be welcome? |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
OK, this is going to be a long post.
What you need. 1. A userform called (mine's called Userform1) with an Image control on it, mine's called Image1. 2. A chart on the active worksheet (mine's called "Chart 2" 3. A button on the worksheet that runs the code to show the userform, i.e. the click event has this code: UserForm1.Show 4. A standard code module. OK, in the standard module copy and paste this code:
On the userform, put this code:
OK, that's all you need. Click your button and the form should show with the graph on the image control. If you need to get rid of the title bar on the userform, search this board. If you can't find it just repost. HTH And if there's any problems, just repost. (Oh yeah, to get the graph to automatically size to fit the Image control, go into the code version of the USerform and click on the Image control, hit "F4" to get the properties window up. Scroll down in the properties window and find the property called "PictureSizeMode" set this to option 1, "fmPictureSizeModeStretch") Phew! |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
Mark
that was a mammoth effort Thanks for the time you took to put that together. The only problem so far is that it stops at "chart 2" Private Sub UserForm_Initialize() ActiveSheet.Shapes("Chart 2").CopyPicture Me.Image1.Picture = PastePicture End Sub Is there something i am doing wrong? this site is awesome!! |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
You need to change "Chart 2" to whatever the name of your chart is.
To find out hold down CTRL and Click on your graph. The combo box to the left of the formula bar will show the name of the chart. PS. The original post only took 10 minutes to knock together. |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Not to take away from Mark but another easier option is to just make your chart visible/Not Visible via the command button ? The Chart after all is just an Object and most excel objects have the Visible property. If you know the name of the Chart then; Sub showChart() Dim Ch As Object '//Change [Chart 1] to the name of your Chart Set Ch = ActiveSheet.Shapes("Chart 1") Ch.Visible = Not (Ch.Visible) DoEvents Application.Wait Now + TimeValue("00:00:10") Ch.Visible = Not (Ch.Visible) Set Ch = Nothing End Sub |
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
Thanks Ivan
The code runs, but the chart remains visible the whole time. Do i need to do something else. Thnaks for your assistance |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Sub showChart() Dim Ch As Object '//Change [Chart 1] to the name of your Chart Set Ch = ActiveSheet.Shapes("Chart 1") Ch.Visible = True DoEvents Application.Wait Now + TimeValue("00:00:10") Ch.Visible = False Set Ch = Nothing End Sub |
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
Ivan
That runs the code and i get a flash of the chart at the end - but not for 10 seconds more like less than 1 sec. thanks for you assistance |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|