Documentazione HotXLS

VBADefined metodo

Restituisce true if Workbook contains VBA code

Sintassi

funzione VBADefined:boolean;

Descrizione

Usa VBADefined before overwriting an existing workbook when your application must preserve files that contain macros. The method is a read-only check; it does not create, remove, o edit VBA modules
In the classic XLS facade, a True result means that the workbook has a VBA project stream. Save the file with an Excel format that can keep VBA content, e avoid exporting it to text, HTML, o RTF if macro preservation is required

Esempio

This example opens an existing workbook e checks whether it contains VBA code before saving it

var
  Workbook: IXLSWorkbook;
begin
  Workbook := TXLSWorkbook.Create;
  try
    Workbook.Open('C:\Reports\Template.xls');

    if Workbook.VBADefined then
      ShowMessage('This workbook contains VBA code.');

    Workbook.SaveAs('C:\Reports\TemplateCopy.xls');
  finally
    Workbook := nil;
  end;
end;

Vedere also