Board index » delphi » Create Excel-Macros in Delphi?

Create Excel-Macros in Delphi?

Hello,

we try to increase the performance by using Excel-Macros. You can save
these macros in a Workbook and load this Workbook at runtime to use the
makros within. But this solution requires to copy the Macro-Workbook to
all users, and loading a Workbook from harddisk is slow.

Is it possible to create Excel-Macros in Delphi5 (without saving macros
to harddisk) by e.g accessing the VBA-Editor (early binding)?

If yes, how?

Thank you in advance,

Karsten.

 

Re:Create Excel-Macros in Delphi?


<<Karsten Hassel:
Is it possible to create Excel-Macros in Delphi5 (without
saving macros to harddisk) by e.g accessing the VBA-Editor
(early binding)?

Quote

You'll find what you need in the VBIDE97.pas or VBIDE2000.pas
files, especially the CodeModule interface declaration. Here's
an example:

var
  LineNo: integer;
  CM: CodeModule;
begin
  CM := WBk.VBProject.VBComponents.Item('ThisWorkbook').Codemodule;
  LineNo := CM.CreateEventProc('Activate', 'Workbook');
  CM.InsertLines(LineNo + 1, '  Range("A4").Value = ""');
  CM.InsertLines(LineNo + 2, '  Range("A4").Select');

--
Deborah Pate

Other Threads