Gruppe
Dialog
Bereich
Diagramm
Thema
Diagramm in Userform
Problem
Wie kann ich in eine Userform ein Diagramm einfügen?
Lösung
Geben Sie den nachfolgenden Code in ein Standardmodul ein und weisen Sie ihn einer Schaltfläche zu.
StandardModule: basMain
Sub GrafikInUserForm()
Const csMsg As String = "Die Statistikgrafik kann nicht " & _
"auf CD-ROM gespeichert werden. Speichern Sie die " & _
"Arbeitsmappe auf Ihrer Festplatte und versuchen " & _
"Sie es erneut."
Dim sFile As String
sFile = ThisWorkbook.Path & "\Statistik.gif"
On Error GoTo ERRORHANDLER
ActiveWorkbook.Charts(1).Export sFile
With frmChart
.imgChart.Picture = LoadPicture(sFile)
.imgChart.PictureSizeMode = fmPictureSizeModeZoom
.Show
End With
Kill sFile
Exit Sub
ERRORHANDLER:
MsgBox prompt:=csMsg
End Sub
ClassModule: frmChart
Private Sub cmdOK_Click()
Unload Me
End Sub