error to show group image to userform

aap

New Member
Joined
Dec 14, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
i have some issue about how to show group image to userform.
i wrote some code to solve this proble but, error happened. ("error" Set CurrentChart = ThisWorkbook.Sheets("Grafik").Shapes("Group 5").Copy)
please help me to solve my problem, i really appreciate all answer. tks

Sub ChangeChart(ChartName As String)
Dim CurrentChart As Shape
Dim NamaGrafik As String
NamaGrafik = ThisWorkbook.Path & "\temp1.gif"
Set CurrentChart = ThisWorkbook.Sheets("Grafik").Shapes("Group 5").Copy
CurrentChart.Export Filename:=NamaGrafik, Filtername:="GIF"
FGRAFIK.Image1.Picture = LoadPicture(NamaGrafik)
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
VBA Code:
Sub SaveShapeAsPicture()
'based on www.thespreadsheetguru.com
Dim cht As ChartObject
Dim ActiveShape As Shape
Dim NamaGrafik As String
NamaGrafik = ThisWorkbook.Path & "\temp1.gif"

Set ActiveShape = ThisWorkbook.Sheets("Grafik").Shapes("Group 5")

'Create a temporary chart object (same size as shape)
  Set cht = ActiveSheet.ChartObjects.Add( _
    Left:=ActiveCell.Left, _
    Width:=ActiveShape.Width, _
    Top:=ActiveCell.Top, _
    Height:=ActiveShape.Height)

'Format temporary chart to have a transparent background
  cht.ShapeRange.Fill.Visible = msoFalse
  cht.ShapeRange.Line.Visible = msoFalse
    
'Copy/Paste Shape inside temporary chart
  ActiveShape.Copy
  cht.Activate
  ActiveChart.Paste
  
'Save chart to User's Desktop as PNG File
  cht.Chart.Export NamaGrafik

'Delete temporary Chart
  cht.Delete

'Re-Select Shape (appears like nothing happened!)
  ActiveShape.Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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