ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Screenupdating (https://www.excelbanter.com/excel-programming/375360-screenupdating.html)

Ozgur Pars[_2_]

Screenupdating
 
Hello,
below is a sequence that I use to update a image(chart) on my userform.
Everytime a user presses this spinbutton the updated chart is loaded on the
userform. The problem I am trying to solve is that although I am using
"screenupdating=false" one can see how the userform is unloaded and then
reloaded. It happens in an instant but why does the screen change at all?
When the userform is hidden the workbook is displayed, would hiding the
workbook help here?

thanks for your help,
Özgür

Private Sub SpinButton92_Change()
Application.ScreenUpdating = False
Label259.Caption = SpinButton92.Value
Sheets("Org_Data").Range("B16") = SpinButton92.Value
Me.Hide
Call Chart
End Sub


Sub Chart()
Application.ScreenUpdating = False
Sheets("Org_Data").Select
ActiveSheet.ChartObjects("Chart 25").Activate
Call example
End Sub


Sub example()
Application.ScreenUpdating = False
ActiveChart.Export "temp.jpg", "JPG", True
UserForm2.Show
'Application.ScreenUpdating = True
On Error Resume Next
Unload UserForm2
Kill "temp.jpg"
On Error GoTo 0
End Sub



NickHK

Screenupdating
 
As I understand it, which may not be correct...
Application.ScreenUpdating refers to Excel. The userform belongs to VBA.
Although the 2 obviously work closely together, they are not one and the
same.
So whilst Excel may not be updating, VBA and your userform are.

I haven't checked your code, but do you actually need the .Select/.Activate
calls ?
Or the userform .Hide/.Show for that matter ?
Can you not just load the new graphic into Image (?) control on the userform
?

NickHK

"Ozgur Pars" wrote in message
...
Hello,
below is a sequence that I use to update a image(chart) on my userform.
Everytime a user presses this spinbutton the updated chart is loaded on

the
userform. The problem I am trying to solve is that although I am using
"screenupdating=false" one can see how the userform is unloaded and then
reloaded. It happens in an instant but why does the screen change at all?
When the userform is hidden the workbook is displayed, would hiding the
workbook help here?

thanks for your help,
Özgür

Private Sub SpinButton92_Change()
Application.ScreenUpdating = False
Label259.Caption = SpinButton92.Value
Sheets("Org_Data").Range("B16") = SpinButton92.Value
Me.Hide
Call Chart
End Sub


Sub Chart()
Application.ScreenUpdating = False
Sheets("Org_Data").Select
ActiveSheet.ChartObjects("Chart 25").Activate
Call example
End Sub


Sub example()
Application.ScreenUpdating = False
ActiveChart.Export "temp.jpg", "JPG", True
UserForm2.Show
'Application.ScreenUpdating = True
On Error Resume Next
Unload UserForm2
Kill "temp.jpg"
On Error GoTo 0
End Sub





Ozgur Pars[_2_]

Screenupdating
 
Nick,
I eliminated the "select" as you suggested and it works smoothly... thanks
for the pointer its definately appreciated.

Regards,
Özgür

"NickHK" wrote:

As I understand it, which may not be correct...
Application.ScreenUpdating refers to Excel. The userform belongs to VBA.
Although the 2 obviously work closely together, they are not one and the
same.
So whilst Excel may not be updating, VBA and your userform are.

I haven't checked your code, but do you actually need the .Select/.Activate
calls ?
Or the userform .Hide/.Show for that matter ?
Can you not just load the new graphic into Image (?) control on the userform
?

NickHK

"Ozgur Pars" wrote in message
...
Hello,
below is a sequence that I use to update a image(chart) on my userform.
Everytime a user presses this spinbutton the updated chart is loaded on

the
userform. The problem I am trying to solve is that although I am using
"screenupdating=false" one can see how the userform is unloaded and then
reloaded. It happens in an instant but why does the screen change at all?
When the userform is hidden the workbook is displayed, would hiding the
workbook help here?

thanks for your help,
Özgür

Private Sub SpinButton92_Change()
Application.ScreenUpdating = False
Label259.Caption = SpinButton92.Value
Sheets("Org_Data").Range("B16") = SpinButton92.Value
Me.Hide
Call Chart
End Sub


Sub Chart()
Application.ScreenUpdating = False
Sheets("Org_Data").Select
ActiveSheet.ChartObjects("Chart 25").Activate
Call example
End Sub


Sub example()
Application.ScreenUpdating = False
ActiveChart.Export "temp.jpg", "JPG", True
UserForm2.Show
'Application.ScreenUpdating = True
On Error Resume Next
Unload UserForm2
Kill "temp.jpg"
On Error GoTo 0
End Sub







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

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