Guinaba
Board Regular
- Joined
- Sep 19, 2018
- Messages
- 233
- Office Version
- 2016
- Platform
- Windows
Hello experts,
I am using a user form to upload two charts, having a option button to switch between them, however I am not able to upload the second chart on the user form, keep getting the - Run time error 481 - Invalid Picture
The code works fine for the first pic, saving it in the correct directory (below), but the second chart the file is saved but with 0 bytes.
I have enough space in my temp folder so space is not an issue.
Form code:
I am using a user form to upload two charts, having a option button to switch between them, however I am not able to upload the second chart on the user form, keep getting the - Run time error 481 - Invalid Picture
The code works fine for the first pic, saving it in the correct directory (below), but the second chart the file is saved but with 0 bytes.
I have enough space in my temp folder so space is not an issue.
VBA Code:
Sub LoadForm()
FormCharts.Show
End Sub
Sub ChangeChart (ChartName As String)
Dim CurrentChart As Chart
Dim FName As String
FName = ThisWorkbook.Path & "\temp.gif"
Set CurrentChart = ThisWorkbook.Sheets("Charts").ChartObjects(ChartName).Chart
CurrentChart.Export Filename:=FName, filtername:="GIF"
FormCharts.ImgChart.Picture = LoadPicture(FName)
End Sub
Form code:
VBA Code:
Private Sub Close_Click()
Unload Me
End Sub
Private Sub Opt2WksCov_Click()
Call ChangeChart("Chart2wks")
End Sub
Private Sub Opt3WksCov_Click()
Call ChangeChart("Chart3wks")
End Sub
Private Sub UserForm_Initialize()
Opt3WksCov.Value = True
End Sub
Attachments
Last edited by a moderator: