You are here: Office-Outlook.com  / Outlook Forum

problem after adding Macro

Home » Outlook addins and plugins development » Developer Outlook add-ins
problem after adding Macro [message #793] Tue, 08 August 2006 03:05 Go to next message
abhijit_ghawate
Messages: 1
Registered: August 2006
Junior Member
Hi,

I am developing a excel addin using c#
on click of a command bar button create a worksheetsheet and add a macro to
the workbook the following way

Microsoft.Vbe.Interop.VBComponent module=null;

module = application.ActiveWorkbook.VBProject.VBComponents.Add(
Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule );

module.Name = "Macro1";
module.CodeModule.AddFromString(macro_string);

i have also added a combo box to the work sheet whose OnAction property i
have set to the above added Macro - Macro1.

when the worksheet is created there is a cell which is selected and i try
typing something, but nothing types, it is as though no cell has been
selected and i am trying to type. Only in this case i actually have a cell
selected. (its wierd...its as if its hung)

Now i go ahead and click on the cell (reselect the cell by mouse) which was
selected and type again. This time it types. But now when i go and click on
the combo-box, the debug code window for the macro opens up and i see the
words i was trying to type before (and were not typed) in the macro code at
the bottom and so the macro actually had a problem executing.

i feel somehow after the macro was added using AddFromString thru C# code
the cursor was put in the Macro code window and after the addition it was
never returned to the excel workseet. Hence when i try to type it gets
written in the macro code window instead of the worksheet.

If anybody knows the problem plase help ...this is driving me crazy...

Thanks
Abhijit
Previous Topic:word 2003 com add-in not working, visual studio 2003
Next Topic:How to open contact pane and select favorite contact folder
Goto Forum: