• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 995
  • Last Modified:

automatically run macro/module after import of .bas file

Hi all,

My code imports a module (.bas file) into an excel file (code is below) but I would like it to automatically run that same module after it is imported. I try to reference the macro name (TestMacro) in teh visual basic express 2010 project that i created but of course it can not refer to it. so is tehre a way to programmably run a macro/module liek this?

thanks in advance,

Simon
ExcelApp.ActiveWorkbook.VBProject.VBComponents.Import(directory2 & "\" & fileName2)

Open in new window

0
touyets17
Asked:
touyets17
1 Solution
 
Rory ArchibaldCommented:
You can't run a module, only a routine, so you would basically use:

ExcelApp.Run "'" & ExcelApp.Activeworkbook.name & "'!macro_name_here"

Open in new window

0
 
touyets17Author Commented:
Perfect!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now