KTR,
Working Hard, or Hardly Working? ;-)
The easiest way is to have the macro in its own module, then use code like
this (which requires a reference to MS VBA Extensibility): change the module
name to match your actual name. The 'myFile' value doesn't need to be
changed, since the file is exported to the default folder, then deleted at
the end of the code.
Sub AddModuleToActiveWorkbook()
Dim myFile As String
myFile = "MyVBAFile.bas"
ThisWorkbook.VBProject.VBComponents("InsertYourAct ualModuleNameHere").Export
(myFile)
ActiveWorkbook.VBProject.VBComponents.Import (myFile)
Kill myFile
End Sub
HTH,
Bernie
MS Excel MVP
"KTR Working Hard" <KTR Working
wrote in
message ...
The VBA Program I'm working with is meant to open another excel document,
make changes to it, save it, and close it.
One of the changes I need to make is to add a drop down/combo box that has
certain abilities. I would like to assign this combo box a macro to run if
changed. How do I pass a macro to this opened excel document through code.
I know in VBA I can just click and drag it. But that does me no help.
Thanks KTR