エクセルVBAのMultipageの使い方について
MultipageにそれぞれImagecontrolを張り付けて
エクセルで自動作成したマーカー付折れ線グラフを
表示させるマクロを書いてみたんですが
2Pageまでは、上手く動作するんですが3page目をクリックしても
全く反応しません。何がおかしいのかどなたかお分かりの方
ご教授下さい。
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
Private Sub MultiPage1_Change()
Application.ScreenUpdating = False
Dim chartrange As Range
Me.MultiPage1.Value = 0
ActiveSheet.Range("a8").CurrentRegion.Select
Set chartrange = Selection
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=chartrange, PlotBy:=xlRows
ActiveChart.Location where:=xlLocationAsObject, Name:="記録"
Const graphimage2 As String = "C:\Users\user\Pictures\Graph.bmp"
If ActiveSheet.ChartObjects.Count = 0 Then Exit Sub
ActiveSheet.ChartObjects(1).Chart.Export graphimage2
If Len(Dir(graphimage2)) > 0 Then
With Image1
.PictureSizeMode = fmPictureSizeModeStretch
.PictureAlignment = fmPictureAlignmentCenter
.BorderStyle = fmBorderStyleNone
.Picture = LoadPicture(graphimage2)
End With
Kill graphimage2
End If
ActiveSheet.ChartObjects.Delete
Me.MultiPage1.Value = 1
ActiveSheet.Range("a11").CurrentRegion.Select
Set chartrange = Selection
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=chartrange, PlotBy:=xlRows
ActiveChart.Location where:=xlLocationAsObject, Name:="記録"
Const graphimage3 As String = "C:\Users\user\Pictures\Graph.bmp"
If ActiveSheet.ChartObjects.Count = 0 Then Exit Sub
ActiveSheet.ChartObjects(1).Chart.Export graphimage2
If Len(Dir(graphimage3)) > 0 Then
With Image2
.PictureSizeMode = fmPictureSizeModeStretch
.PictureAlignment = fmPictureAlignmentCenter
.BorderStyle = fmBorderStyleNone
.Picture = LoadPicture(graphimage3)
End With
Kill graphimage3
ActiveSheet.ChartObjects.Delete
End If
Me.MultiPage1.Value = 2
ActiveSheet.Range("a14").CurrentRegion.Select
Set chartrange = Selection
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=chartrange, PlotBy:=xlRows
ActiveChart.Location where:=xlLocationAsObject, Name:="記録"
Const graphimage4 As String = "C:\Users\user\Pictures\Graph.bmp"
If ActiveSheet.ChartObjects.Count = 0 Then Exit Sub
ActiveSheet.ChartObjects(1).Chart.Export graphimage4
If Len(Dir(graphimage4)) > 0 Then
With Image3
.PictureSizeMode = fmPictureSizeModeStretch
.PictureAlignment = fmpictueralignmentcenter
.BorderStyle = fmBorderStyleNone
.Picture = LoadPicture(grphimage4)
End With
Kill graphimage4
End If
ActiveSheet.ChartObjects.Delete
Application.ScreenUpdating = True
End Sub
お礼
ありがとうございました 解決しました