I use c# to start excel and to get numberformat of active cell. VBA outputs
results as expected, but via c# i get result 'Standard' instead of 'General'
for a call to numberformat. Why?
It look's like 'numberformatlocal' is returned instead of 'numberformat'.
Output of C#:
Numberformat:Standard
NumberformatLocal:Standard
Output of VBA:
Numberformat:General
NumberformatLocal:Standard
System:
- Windows XP, SP1
- Excel 2002, SP2
Note: I'm from austria - language is german
wkr
Robert
---------------------------------------------
C#
Expand|Select|Wrap|Line Numbers
- using System;
- using Excel;
- namespace ConsoleApplication1 {
- class Class1 {
- [STAThread]
- static void Main(string[] args) {
- Excel.Application app = new Excel.Application();
- app.Visible = true;
- try {
- app.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
- _Worksheet worksheet = (_Worksheet) app.ActiveSheet;
- if (worksheet == null) {
- Console.WriteLine ("ERROR: worksheet == null");
- }
- Console.WriteLine("Numberformat:"+app.ActiveCell.NumberFormat);
- Console.WriteLine("NumberformatLocal:"+app.ActiveCell.NumberFormatLocal);
- } catch (Exception e) {
- Console.Out.WriteLine(e);
- }
- app.Quit();
- }
- }
- }
VBA
Expand|Select|Wrap|Line Numbers
- Sub test()
- Debug.Print "Numberformat:" & ActiveCell.NumberFormat
- Debug.Print "NumberformatLocal:" & ActiveCell.NumberFormatLocal
- End Sub