EXCELのグラフ
下のようにVBからExcel にデータを送りグラフを表示しています。
印刷プレビューを表示したときにグラフと表が表示されてしまいます。グラフだけを表示して表は表示をしたくないのですが
どうすればいいのでしょうか
お願いします。
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
Dim i As Integer
Dim j As Integer
For i = 2 To 6
For j = 2 To 6
xlSheet.Cells(j, i) = CInt(71 * Rnd + 30)
Next j
Next i
xlSheet.Cells(2, 1) = "国語"
xlSheet.Cells(3, 1) = "数学"
xlSheet.Cells(4, 1) = "英語"
xlSheet.Cells(5, 1) = "社会"
xlSheet.Cells(6, 1) = "体育"
xlSheet.Cells(1, 2) = "石原"
xlSheet.Cells(1, 3) = "小泉"
xlSheet.Cells(1, 4) = "田中"
xlSheet.Cells(1, 5) = "平沼"
xlSheet.Cells(1, 6) = "森山"
Dim MyChart As ChartObject
Set MyChart = xlSheet.ChartObjects.Add(10, 100, 600, 330)
With MyChart.Chart
.SetSourceData xlSheet.Range("A1:F6"), xlColumns
.Axes(xlValue).MaximumScale = 100
.Axes(xlValue).MajorUnit = 20
.HasTitle = True
.ChartTitle.Text = "中間テスト結果"
.ApplyDataLabels (xlDataLabelsShowValue)
.Location xlLocationAsObject, xlSheet.Name
End With
xlApp.Visible = True
With xlSheet.PageSetup
.PaperSize = xlPaperA4
.Orientation = xlPortrait
.LeftMargin = xlApp.CentimetersToPoints(2)
.RightMargin = xlApp.CentimetersToPoints(2)
.TopMargin = xlApp.CentimetersToPoints(2.5)
.BottomMargin = xlApp.CentimetersToPoints(2.5)
.HeaderMargin = xlApp.CentimetersToPoints(1)
.FooterMargin = xlApp.CentimetersToPoints(1)
End With
xlSheet.PrintPreview
Set MyChart = Nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub