macro problem

  • Thread starter Thread starter TommyBoy
  • Start date Start date
T

TommyBoy

i have a macro i created that emails worksheets, it needs to be used on
different workbooks, but when i import it into a workbook at runtime it
doesn't find it, do i have to save the vbproject first? or does anyone
know what is going on?
 
How did you create the macro?
If you use the VBA editor you can save the macro as part of a worksheet or
in the xlb file so it will be there everytime you launch Excel.

Inbar.
 
i created the macro in one worksheet and then exported it to use it in
other files, because other excel apps will need to use, so i'm trying to
do it at run time like this: (it says it can't find the macro)

//this will add a reference to outlook
excelWorkbook.VBProject.References.AddFromFile(@"C:\Program
Files\Microsoft Outlook\OFFICE11\msoutl.olb");

//this imports the macro to my file
excelWorkbook.VBProject.VBComponents.Import(@"C:\Temp\ActiveSheet.bas");

//this runs it
excelApp.GetType().InvokeMember("Run",System.Reflection.BindingFlags.Default
| System.Reflection.BindingFlags.InvokeMethod,null, excelApp,new
Object[]{"'" + emFile.Name.ToString().Trim() +
"'!SendActiveSheet.SendActiveSheet"});
 
how do i save it to the xlb file?
How did you create the macro?
If you use the VBA editor you can save the macro as part of a worksheet or
in the xlb file so it will be there everytime you launch Excel.

Inbar.

:
 
You don't save macros to xlb files. Inbar is mistaken. xlb files hold
menu modifications.
 
You open the xlb from excel, go to VBA, import the code, and save it back to
the xlb.
 
Hi Inbar,

See Tom Ogilvy's adjacent response to TommyBoy!

The xlb file stores toolbar customisations - it does not (and cannot) store
macros. Opening the xlb file restores the toolbar configurations that
applied when Excel was last closed, it does not present a VBA-readable file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top