Exemplo n.º 1
0
 protected override void Action()
 {
     base.Action();
     Wb.Activate();
     Ws.Select();
     if (Range != null && (!Range.Equals("")))
     {
         App.Range[Range].Select();
     }
 }
Exemplo n.º 2
0
 protected override void Action()
 {
     base.Action();
     //运行宏
     if (FunctionName.CheckNoVoid())
     {
         Wb.Activate();
         try
         {
             RunVBA();
         }
         //沒有信任存取VAB專案物件模型
         catch (System.Runtime.InteropServices.COMException come)
         {
             //插入VBA代码
             if (VBACode.CheckNoVoid())
             {
                 try
                 {
                     VBE         vbe = App.VBE;
                     VBComponent vbComponent;
                     vbComponent = Wb.VBProject.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule);
                     vbComponent.CodeModule.AddFromString(VBACode);
                 }
                 catch (Exception e)
                 {
                     throw new ActionException("添加vb函數失敗\n" + e.ToString());
                 }
                 RunVBA();
             }
             else
             {
                 throw come;
             }
         }
     }
 }