Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I generate a new excel file from with code (C#), in this new excel I write data, ... As a final step I need to call some code (formatting written as a macro and stored in a module.bas). I want to load this module dynamically from within my newly created excel file, but I don't find how I can do this. Can anybody help me with this? Thanks, Laura G. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Just found in my data that Chip Pearson shows on his site how to do this. Regards JY "Laura G." wrote in message ... Hello, I generate a new excel file from with code (C#), in this new excel I write data, ... As a final step I need to call some code (formatting written as a macro and stored in a module.bas). I want to load this module dynamically from within my newly created excel file, but I don't find how I can do this. Can anybody help me with this? Thanks, Laura G. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
xlApplication.Run "MacroName" where xlApplication is your Excel.Application variable "MacroName" is the name of the subroutine you want to execute. "Laura G." wrote: Hello, I generate a new excel file from with code (C#), in this new excel I write data, ... As a final step I need to call some code (formatting written as a macro and stored in a module.bas). I want to load this module dynamically from within my newly created excel file, but I don't find how I can do this. Can anybody help me with this? Thanks, Laura G. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The sytax I gave is for VB. There should be an equivalent for C#. The main
point is to use the Run method of the Excel Application object. "Vergel Adriano" wrote: Try xlApplication.Run "MacroName" where xlApplication is your Excel.Application variable "MacroName" is the name of the subroutine you want to execute. "Laura G." wrote: Hello, I generate a new excel file from with code (C#), in this new excel I write data, ... As a final step I need to call some code (formatting written as a macro and stored in a module.bas). I want to load this module dynamically from within my newly created excel file, but I don't find how I can do this. Can anybody help me with this? Thanks, Laura G. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found my answer indeed; for others looking at this:
app = new Excel.Application(); app.Workbooks.Open(filename,Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Excel.Workbook wb = app.Workbooks[1]; //open a saved module ex: c:\module1.bas wb.VBProject.VBComponents.Import(vbFileName); app.Run(macroName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); wb.Save(); app.Quit(); "Jean-Yves" wrote: Hi, Just found in my data that Chip Pearson shows on his site how to do this. Regards JY "Laura G." wrote in message ... Hello, I generate a new excel file from with code (C#), in this new excel I write data, ... As a final step I need to call some code (formatting written as a macro and stored in a module.bas). I want to load this module dynamically from within my newly created excel file, but I don't find how I can do this. Can anybody help me with this? Thanks, Laura G. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel loading | Excel Discussion (Misc queries) | |||
Disable VBA code execution when loading a workbook | Excel Discussion (Misc queries) | |||
Loading excel | Excel Discussion (Misc queries) | |||
Addins not loading when opening from code | Excel Programming | |||
Excel Add-In loading | Excel Discussion (Misc queries) |