Excelの起動

「プロジェクト」 - 「参照設定」

Public ExcelApp As Excel.Application

'----------     'Excel起動     ----------  
Public Function ExcelInit()
    On Error Resume Next
    
    Set ExcelApp = GetObject(, "Excel.Application")
    
    If Err Then
        Set ExcelApp = CreateObject("Excel.Application")
        
        Err.Clear
        
    End If
        
    ExcelApp.Visible = True
    
    Debug.Print ExcelApp.Version

End Function
   
 
'----------     サンプル     ----------     
Public Sub Module_()

    'Excel起動
    Call ExcelInit
  
    Dim ExBk As Workbook
    Dim ExSt As Worksheet
       
    Set ExBk = ExcelApp.ActiveWorkbook
    Set ExSt = ExcelApp.ActiveSheet

    'Excel解放
    Set ExcelApp = Nothing
    
    Exit Sub

End Sub    
	    


<戻る>

Gポイントポイ活 Amazon Yahoo 楽天

無料ホームページ 楽天モバイル[UNLIMITが今なら1円] 海外格安航空券 海外旅行保険が無料!