タイトル | : プロセスのExcelが残ってしまう |
記事No | : 13169 |
投稿日 | : 2008/10/23(Thu) 18:19 |
投稿者 | : ぴょん太 |
長文です。 いつもお世話になっております。
現在、実行処理を行った際、 Excel.exeが終了されていない状況となっております。 手順としては @Excel開く AExcelにデータ書き込み Bデータを元にグラフを作成 CExcel閉じる
@⇒A⇒Cの手順ですと、 正常にExcel.exeが消えます。 2回目以降の実行処理を行った際も問題ありません。 Bの内容が以下の内容となります。
環境:Windows2000 VB6.0です よろしくお願いします。
****************************************************************** Dim xlsSheet As Excel.Worksheet Dim Shapes As Excel.Shapes Set xlsSheet = xlsBooks(alngSouNo).Sheets(astrSheet) '初期設定 Range("A1:J13").Select Range("J13").Activate Charts.Add ActiveChart.ChartType = xlLineMarkers ActiveChart.SetSourceData Source:=Sheets(astrSheet).Range("A1:J13"), PlotBy _ :=xlColumns 'グラフ表示場所変更(Sheet1⇒Sheet2) ActiveChart.Legend.Select ActiveChart.ChartArea.Select ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Dim cht As Object Dim cht2 As String For Each cht In ActiveSheet.ChartObjects cht2 = cht.Name Next cht2 = Right$(cht2, 1) ActiveSheet.Shapes("グラフ " & cht2).IncrementLeft -210# ActiveSheet.Shapes("グラフ " & cht2).IncrementTop 81# Windows(astrExcel & ".xls").SmallScroll Down:=12 ActiveSheet.Shapes("グラフ " & cht2).ScaleWidth 1.32, msoFalse, msoScaleFromTopLeft ActiveSheet.Shapes("グラフ " & cht2).ScaleHeight 1.48, msoFalse, msoScaleFromTopLeft 'フォントサイズ変更(下…期間) ActiveSheet.ChartObjects("グラフ " & cht2).Activate ActiveChart.Axes(xlCategory).Select Selection.TickLabels.AutoScaleFont = True With Selection.TickLabels.Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With 'フォントサイズ変更(左…値) Selection.TickLabels.AutoScaleFont = True With Selection.TickLabels.Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With '指定行のn番目第二軸に変更 ActiveChart.SeriesCollection(7).AxisGroup = 2 ActiveChart.SeriesCollection(8).AxisGroup = 2 ActiveChart.SeriesCollection(9).AxisGroup = 2 'グラフ内の各ポイントに値表示 '凡例を下中央に変更 ActiveChart.HasLegend = True ActiveChart.Legend.Select Selection.Position = xlBottom ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False 'グラフ内の値文字一括設定 Selection.AutoScaleFont = True With Selection.Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With ActiveChart.Axes(xlValue, xlSecondary).Select 'グラフ内の値文字(右)設定 Selection.TickLabels.AutoScaleFont = True With Selection.TickLabels.Font .Name = "MS Pゴシック" .FontStyle = "太字" .Size = 9 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 7 .Background = xlAutomatic End With ActiveChart.Axes(xlValue).Select 'グラフ内の値文字(左)設定 Selection.TickLabels.AutoScaleFont = True With Selection.TickLabels.Font .Name = "MS Pゴシック" .FontStyle = "太字" .Size = 9 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 50 .Background = xlAutomatic End With ActiveChart.Axes(xlValue, xlSecondary).Select ActiveChart.Axes(xlValue).Select With ActiveChart .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "数値軸" .Axes(xlValue, xlSecondary).HasTitle = True .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "%軸" End With ActiveChart.Axes(xlValue).AxisTitle.Select Selection.AutoScaleFont = True With Selection.Font .Name = "MS Pゴシック" .FontStyle = "太字" .Size = 9 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 50 .Background = xlAutomatic End With With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .Orientation = xlVertical End With ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Select Selection.AutoScaleFont = True With Selection.Font .Name = "MS Pゴシック" .FontStyle = "太字" .Size = 9 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 7 .Background = xlAutomatic End With With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .Orientation = xlVertical End With '軸のフォントサイズ修正 Dim lngIndex As Long For lngIndex = 1 To 9 ActiveChart.SeriesCollection(lngIndex).DataLabels.Select Selection.AutoScaleFont = True With Selection.Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 7 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With Next lngIndex 'グラフ表示位置修正 ActiveSheet.Shapes("グラフ " & cht2).ScaleWidth 1.32, msoFalse, msoScaleFromTopLeft ActiveSheet.Shapes("グラフ " & cht2).ScaleHeight 1.48, msoFalse, msoScaleFromTopLeft 'グラフ表示場所変更(Sheet1⇒Graph) ActiveChart.Location Where:=xlLocationAsNewSheet Set xlsSheet = Nothing Set Shapes = Nothing ******************************************************************
|