ぴょん備忘録

ソフトエンジニアのしょぼい備忘録です。
転載はしないでください。


テーマ:
Dim exApp As New Object

'起動
exApp = New Excel.Application()
 '新ブック追加
Dim book As Excel.Workbook = exApp.Workbooks.Add()
 'シート1を取得
Dim sheet As Excel.Worksheet = book.Worksheets(1)

'ブックClose
book.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComObject(book)
book = Nothing
'終了
exApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(exApp)
exApp = Nothing

同じテーマの最新記事

テーマ:
'セル範囲用オブジェクト定義&初期化
Dim range As Excel.Range = Nothing

'セル幅の自動調整
range = DirectCast(sheet.Range("A:A"), Excel.Range)
range.EntireColumn.AutoFit()

'セル行高の自動調整
range = DirectCast(sheet.Range("1:1"), Excel.Range)
range.EntireRow.AutoFit()

'セルの結合
sheet.Range("A1:A2").MergeCells = True

'罫線を線幅wで引く
With sheet.Range("A1:B2")
      '範囲の左側
      .Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = w
      '範囲の左側
      .Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = w 
      '範囲の右側
      .Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = w
      '範囲の下側
      .Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = w 
End With

Amebaおすすめキーワード