This Domain Is For Sell, Contact: admin@mrvsto.com
Apr 172010
 

Code:

private void ThisWorkbook_Startup(object sender, System.EventArgs e)
  {
      string sCode = "Sub VBAMacro()\r\n" + "MsgBox \"Test\"\r\n" + "End Sub";
      VBComponent oModule;
      oModule = Globals.ThisWorkbook.VBProject.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule);
      oModule.CodeModule.AddFromString(sCode);
  }




Hot:

● Use Microsoft Office 2007 like a Pro!
● Excel Expert User-Your One Stop Solution In Mastering Microsoft Excel
● 101 Secrets of a Microsoft Excel Addict
● Excel VBA Made Easy
● Doc2Txt
● Create Your Own Programming Language



Author:laoyebin (Paladin.lao)
From:VSTO&Excel Space of Paladin Lao
Post :VSTO/VBA: Use VSTO to add VBA code

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>