where do I find docs on excel automation programming?

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

From c# I start excel, open a workbook and run a specfic macro. I have code
to do this but I don't know how to pass a parameter to the macro and I
cannot find an documentation on it.

This is my code, I believe one of the missing.values can be a parameter but
not sure

oXL.Workbooks.Open(strFileName, 0, false, 5, "", "", false,
Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
oXL.Application.Run("ThisWorkbook.ProcessKrunFile",
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value);

thanks
 
Looks like ProcessKrunFile is a macro in ThisWorkbook: how can you/anyone
write a macro which need 30 arguments?

Excel macros accept their parameters by position (i.e. you supply every
parameter in the order listed in the header of the macro) or by name. Eg

ActiveWorkbook.SaveAs FileName:="c:\xx.xls" Format:=xlNormal

The advantage in passing parameters by name is that the parameters you do
not specify inherit a default value in the Excel Object.

I don't know how you specify := in C# and I believe Excel constants (like
xlNormal) are likely to be unavailable and you will have to specify the
value; the later is easy, you can find out from Excel via its help or simply
type ?xlNormal in the Immediate Window of the VBE. There must be an example
that illustrates how to code := in C#.

I'd search for "Excel" "Interrop" in Google; you might be lucky.
 
Back
Top