���³���������������Ï�����¾���¹�����������¡�VBA����\���\���\�������������VB.NET���«������¼���¹��ԏ��·�����ď��������³���������̏���������¡�
���½�������������������������������������������������¹��������¡�
�돪�²¼��¡�\µ\���\��\�����¡�
������»²¾��������Ώ����������ҏ�����²������¹��������¡�
�����¡��COM\³\���\����¼\���\���\���������Microsoft Excel xx.x Object Library�����ҏ�����²������¹��������¡�
������Imports������������Microsoft.Office.Interop.Excel�����ҏ��������������¹��������¡�
����\³���¼\�������
'[»²¾��������Ώ���������������²���]-[COM]\���\��ӏ��«������
'Microsoft Excel xx.x Object Library�����ҏ����쏪���ҏ��¹����������̏���ߏ���������¡�
Imports Excel = Microsoft.Office.Interop.Excel
Private Sub Main()
����Dim oExcel As Excel.ApplicationClass
����Dim oBook As Excel.WorkbookClass
����Dim oBooks As Excel.Workbooks
����Dim strPath As String
����'C:\Test.xls������¼���¹���\���\���\���\���������»������������¹��������¡�
����strPath = "C:\Test.xls"
����'Excel\���\���\���\��\���\���������돫�����
����oExcel = New Excel.Application
����'oExcel = CreateObject("Excel.Application")
����oExcel.Visible = True
����oBooks = oExcel.Workbooks
����'Excel\���\���\���\���������³«������
����oBook = oBooks.Open(strPath)����
����'\���\���\���������¼���¹��ԏ��¹������
����oExcel.Run("Test")
����oExcel.Run("TestWithParameter", "Hello from VB .NET Client")
����'������½���������
����oBook.Close(False)
����System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
����oBook = Nothing
����System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
����oBooks = Nothing
����oExcel.Quit()
����System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
����oExcel = Nothing
End Sub
¾���µ������\³���¼\����������¾��������¡�C\���\���\���\��ӏ������¾²¼������"Test.xls"�����ҏ�돫�����¹����������̏���ߏ��̏���������¡��³������Excel\���\���\���\�����������������¡�VBA����������½���\���\���\������¼\��������ҏ�����²������·��¡�돪�²¼�������¾����돢����»��������������ď�ԏ����ҏ�돫�����¹����������̏���ߏ��̏���������¡�½��������������������������������������������Ï���������������������������¹½���������������������̏�¡�\���\���\»���¼\���\���\���\���\¹�����ҏ��½¼�����µ���»����������������돢돫��·���������������������³����������³���������·��ߏ�������¡�
������Test
������TestWithParameter(strParam As String)
���⏪�������»���¹�������
���Ï��¾������Office���½����������Word, PowerPoint, Access����������VBA������»�������ď����������Ï�����������������¼���¹���²������½��¡�
����1.���о����������¹���������½������������»²¾��������Ώ����������ҏ�����²������¹������
����2.���Ð�ޏ�Џ��¹������\���\���\¹������Imports���¹��������¡�
������Access������¾���¹�������������Microsoft.Office.Interop.Access
������Word������¾���¹�������������Microsoft.Office.Interop.Word
������PowerPoint������¾���¹�������������Microsoft.Office.Interop.PowerPoint
����3.���½���������������Ð�ޏ�Џ��¹������\���\���\���\��\���\���������\������¼\���·��ď��������·������»��������Џ��¹��������¡�
����Run\���\½\���\�������������1�돫⏢ď�ԏ��̏�¡�¼���¹��ԏ��¹�������������ď�ԏ��¾��¡���2�돫⏢ď�ԏ���\���\���\������¼\��ď�������������������������������������¡�
- \«\���\��\�����¡�
- VB.NET
- VBA(MS-Office)