Re: Creating an Excel Automation Add-In using C#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Peter Huang (v-phuang_at_online.microsoft.com)
Date: 12/06/04

  • Next message: Katrin Bibas: "Stream content into AxSHDocVw.AxWebBrowser"
    Date: Mon, 06 Dec 2004 03:37:00 GMT
    
    

    Hi

    For Q1, I think this may be caused by the different locale, e.g. you set
    the locale A in the code, while the excel.exe will get the locale setting
    in the system setting which may be different which cause the problem.

    For Q2, as we know that the excel is kind of electronical sheet computing
    tool which is based on the cell. So if our formula is as below.
    =(A1+A2)
    once A1 or A2 is changed the formula will be recalculated( if we have turn
    on the option of automatically)
    While if the formula has nothing to do with the cell change, then the excel
    have no idea about the change.
    =filevalue()
    because the excel will not detect the file has changed, it is also not the
    excel's responsibility to do the job.

    For now I think we have two options.
    1. LoadFile based on a cell value so that whenever the cell is changed ,
    the formula will be recalculated.
            public double LoadFile(double i)
                    {
                            System.Diagnostics.Debug.WriteLine("LoadFile() Called");
                            StreamReader sr = new StreamReader(@"c:\temp\redist.txt");
                            string str =sr.ReadToEnd();
                            sr.Close();
                            return str.Length;
                    }

    2. Write a Macro as below, which will be called whenever you want to
    recalculate the formula,e.g. in the workbook_open ...
    Sub Test()
    Sheet1.Range("D10").Formula =
    "=AutomationAddin.MyFunctionsTest.LoadFile(A1)"
    End Sub

    Hope this helps.

    Best regards,

    Perter Huang
    Microsoft Online Partner Support

    Get Secure! - www.microsoft.com/security
    This posting is provided "AS IS" with no warranties, and confers no rights.


  • Next message: Katrin Bibas: "Stream content into AxSHDocVw.AxWebBrowser"

    Relevant Pages

    • Re: Stop specific cell from recalculating?
      ... Microsoft Excel MVP ... macros that will only recalculate specific cells when Recalc is set to ... customer ID changes in a cell, the cell next to it may recalculate, ... formulas in every worksheet that uses the functions. ...
      (microsoft.public.excel.worksheet.functions)
    • Re: Excel 2003 BOM Cost roll-up Function
      ... Application.volatile means that the function will recalculate when excel ... recalculates--not when a cell changes. ... If you really want it to know when it should recalculate, ... Dim Sum As Double ...
      (microsoft.public.excel.misc)
    • Re: VBA function wont update in worksheet
      ... from worksheet cells is to include *everything* that is needed by the ... cell when it needs to be calculated; that is, when a precedent of the cell ... Excel may not recalculate the function when that cell changes ...
      (microsoft.public.excel.programming)
    • Re: How to search a cell for multiple keywords?
      ... I'm searching for about 10 different groups of keywords (e.g. 1: ... formula and want to recalculate, Excel takes forever. ... criteria are present in any cell in that range - it will return a 1. ...
      (microsoft.public.excel.programming)
    • Re: Display the TEXT of a comment in a new cell
      ... The UDF could be one calculation cycle behind. ... Changing the comment doesn't make the function recalculate. ... But by making a change to the cell, excel thought ...
      (microsoft.public.excel)