0

Outlook にマクロがあり、デスクトップに保存されている Excel ファイルを開いています。ファイルが開いたら、Excel で記述したマクロを実行したいのですが、使用できる Excel マクロがありません。他の方法で Excel を開くとマクロが使用可能になり、Outlook vba から Excel を開くとマクロが有効になります。私の質問は、Outlook マクロを介して Excel を開くときにこれらのマクロを使用できるようにするにはどうすればよいですか? 以下の私のコードを参照してください。

'Pre:None
'Post:Excel will have been opened, and the macro "CreatePowerPoint()"
'     will have been run on the excel document
Sub Gimba()
    Dim xlApp As Object, xlWkb As Object
    'open excel
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True ' can be False if you do not wont see reaction,
                     ' byt make sure is not fail
    'Do not show any alerts
    xlApp.DisplayAlerts = False

    'open excel document
    Set xlWkb = xlApp.Workbooks.Open(file path goes here)

    'call macro on excel document
    Call xlApp.Run("CreatePowerPoint")
End Sub
4

1 に答える 1