UserForm Refresh/Reload

towners

Board Regular
Joined
Mar 12, 2009
Messages
225
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have nice "Master" userform that opens when the workbook starts and acts as the starting and central point for a small performance reporting application I'm writing. The userform shows 3 charts, captured as .gif and 3 command buttons that open userform for data entry, and detail reports.

The charts that are displayed on the master userform are dynamically updated through the data entry function and refreshed when the user has finished entering data.

What I want is when the user closes the data entry userform for the .gifs to be refreshed. At the moment, to do this I have code from within my data entry userform (cmd button close) that unloads the data entry form and then unloads and reloads my Master userform to process the Initialize command that captures the charts and presents them.

I'd rather just refresh the .gifs than reload the complete userform to make the process smooth and quicker.

Can anyone help out?

Here's the code:

Master Userform Initialize and Chart Presentation:

Code:
Private Sub UserForm_Initialize()
ChartNum = 1
UpdateChart_OverallOEE
UpdateChart_OverallUnits
UpdateChart_OverallWeights
 
End Sub
Private Sub UpdateChart_OverallOEE()
    Set CurrentChart = Sheets("Chart_OverallOEE").ChartObjects(ChartNum).Chart
    CurrentChart.Parent.Width = 710
    CurrentChart.Parent.Height = 150
'   Save chart as GIF
    Fname = ThisWorkbook.Path & Application.PathSeparator & "Chart_OverallOEE.gif"
    CurrentChart.Export Filename:=Fname, FilterName:="GIF"
'   Show the chart
    img_Chart_OverallOEE.Picture = LoadPicture(Fname)
End Sub
Private Sub UpdateChart_OverallUnits()
    Set CurrentChart = Sheets("Chart_OverallUnits").ChartObjects(ChartNum).Chart
    CurrentChart.Parent.Width = 700
    CurrentChart.Parent.Height = 150
'   Save chart as GIF
    Fname = ThisWorkbook.Path & Application.PathSeparator & "Chart_OverallUnits.gif"
    CurrentChart.Export Filename:=Fname, FilterName:="GIF"
'   Show the chart
    img_Chart_OverallUnits.Picture = LoadPicture(Fname)
End Sub
Private Sub UpdateChart_OverallWeights()
    Set CurrentChart = Sheets("Chart_OverallWeights").ChartObjects(ChartNum).Chart
    CurrentChart.Parent.Width = 700
    CurrentChart.Parent.Height = 175
'   Save chart as GIF
    Fname = ThisWorkbook.Path & Application.PathSeparator & "Chart_OverallWeights.gif"
    CurrentChart.Export Filename:=Fname, FilterName:="GIF"
'   Show the chart
    img_Chart_OverallWeights.Picture = LoadPicture(Fname)
End Sub

Data Entry "Close Button" Code:
Code:
Private Sub cmd_Close_Click()
Application.Calculate
ActiveWorkbook.RefreshAll
Public_Modify = 0
Public_TimeOn = 0
Public_TimeOff = 0
Public_TimeDiff = 0
Public_QtyActivity = 0
Public_TurnOnEnter = 0
Unload CellDataEntry
Unload Master
Master.Show

Appreciate any tips/advice

Thanks

Paul
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
try changing

Code:
Private Sub UserForm_Initialize()

to
Code:
Private Sub UserForm_Activate()
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,038
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top