假定book1.xls中有宏为:  宏1()
则它的路径为:
      ActiveWorkbook.Application.run('book1.xls!宏1');

解决方案 »

  1.   

    我用C++BUILDER都做起来了,用DELPHI应该更简单
    供你参考#include <vcl.h>
    #pragma hdrstop#include "Unit1.h"
    #include <utilcls.h>      // util classes实用类说明
    #define   PG   OlePropertyGet
    #define   PS   OlePropertySet
    #define   FN   OleFunction
    #define   PR   OleProcedure
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
    {
         Variant Ex,Wb;
         try
             {
               Ex=Variant::CreateObject("Excel.Application");
             }
         catch(...)
             {
             }
         if (VarIsEmpty(Ex))
            {
               ShowMessage("系统没有 Ms Excel !");
               return;
            }
         Ex.PS("Visible",false);          // Excel 是否可见
         Ex.PS("DisplayAlerts",false);    // 是否要出现警告
         Wb=Ex.PG("WorkBooks").FN("Open","c:\\test宏\\book1.xls");
         Wb.PG("Application").PR("run","book1.xls!宏1");
         Ex.PR("Quit");                // 退出Ms Excel
    }
    //---------------------------------------------------------------------------
      

  2.   

    下面是宏的内容:Sub 宏1()
    '
    ' 宏1 宏表
    ' hp记录的宏2001-4-10
    '
        
      MsgBox "执行宏了", vbOKOnly, "标题"
         End Sub
      

  3.   

    用VBA,可以参考VBAXL8.HLP。应该在OFFICE目录下或安装盘中可以找到