Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - Writing Excel Addons
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Writing Excel Addons
By: David Bolton
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2004-12-14

    Table of Contents:
  • Writing Excel Addons
  • Huge Strings are a Huge Mistake
  • Xloper Definition
  • Caution- Recalculation Alert!
  • Getting Values from an Excel Spreadsheet
  • Reading Cell Values
  • Putting values into Excel Cells
  • An example Add-In

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Writing Excel Addons - Xloper Definition


    (Page 3 of 8 )

    TVal = packed Record
               Case Byte of
               1: (num: Double); (* xltypeNum *)
               2: (str: ^ShortString); (* xltypeStr *)
               3: (bool: Word); (* xltypeBool *)
               4: (err: Word); (* xltypeErr *)
               5: (w: Integer); (* xltypeInt *)
               6: (sref : packed record
                     count:word;
                     ref: Xlref;
                   end);
               8: (_array : packed Record (* xltypeMulti *)
                             lparray: LPXLOPERArray;
                             rows: WORD;
                             columns: WORD;
                           End);
               9: (mref : packed record // xltyperef
                             lpmref : lpxlmref;
                             idsheet : integer;
                           End);
              End; // tval

      XlOper = packed Record
                 val: TVal;
                 xltype: WORD;
                 dummy:array[0..5] of byte; // pads to 16 byte size
               End;
    lpxloper = ^xloper;

    Problem with Excel calls

    From Delphi the big stumbling block with add-ins is the extra parameter after the return address on the stack. This comes free with every call to Excel. I’ve never found out what it holds, but so long as you throw it away, your add-in will work fine. Add the line asm pop variable, end; after every call where variable can be any global, local or object variable that is at least 4 bytes long- integer is fine. To repeat- THIS MUST BE INCLUDED after every Excel4v call. Otherwise you are constructing a time-bomb.

    Example

    Eresult:= Excel4V(xlfCaller,@xres,0,[nil]);
    asm pop sink; end; // Never Remove

    Note that with Delphi syntax, if xres is an xloper, you can use @xres to define an lpxloper.

    More Windows Scripting Articles
    More By David Bolton


     

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT