3

アクセスで VBA を使用して、「呼び出し関数」を使用して Excel でマクロを実行することはできますか? Access の VBA 関数を使用して、データをフォーマットしようとしています。

4

1 に答える 1

1

はい、可能です。

次に例を示します。

Sub RunExcelMacro()
Dim xl As Object
'Step 1:  Start Excel, then open the target workbook.
    Set xl = CreateObject("Excel.Application")
    xl.Workbooks.Open ("C:\Book1.xlsm")

'Step 2:  Make Excel visible
    xl.Visible = True

'Step 3:  Run the target macro
    xl.Run "MyMacro"

'Step 4:  Close and save the workbook, then quit the Excel application
    xl.ActiveWorkbook.Close (True)
    xl.Quit

'Step 5:  Memory Clean up.
    Set xl = Nothing

End Sub
于 2013-10-17T18:15:43.657 に答える