Problem with Automation Excell

DavisDavis Member Posts: 8
edited 2002-08-16 in Navision Attain
I want to use Validation.Add function, but if I try to compile the "NonWorkig CODE" (see below), the Navision Attain ends with message:
"fin.exe generated errors and will be closed by windows. You will need to restart the program"
but if I use the "Working Code" all is ok, and work correctly.
Doe's anybody have an idea how to make it to work?

++++++++++++ VAR ++++++++++++++
XlsApp Automation 'Microsoft Excel 9.0 Object Library'.Application

XlsSheet Automation 'Microsoft Excel 9.0 Object Library'.Worksheet

XlsSheets Automation 'Microsoft Excel 9.0 Object Library'.Sheets

TextCustContact Code 1024
+++++++++++ CODE NonWorking ++++++++++++
CREATE(XlsApp);
XlsApp.Workbooks.Add;
XlsSheets := XlsApp.ActiveWorkbook.Sheets;

TextCustContact := 'A;B;C;D';

XlsSheet := XlsSheets.Item(1);
WITH XlsSheet.Range('A1').Validation DO BEGIN
Add(3,1,1,TextCustContact);
IgnoreBlank := TRUE;
InCellDropdown := TRUE;
ShowInput := TRUE;
ShowError := TRUE;
END;

+++++++++++ CODE Working ++++++++++++
CREATE(XlsApp);
XlsApp.Workbooks.Add;
XlsSheets := XlsApp.ActiveWorkbook.Sheets;

//TextCustContact := 'A;B;C;D';

XlsSheet := XlsSheets.Item(1);
WITH XlsSheet.Range('A1').Validation DO BEGIN
Add(3,1,1,'A;B;C;D');
IgnoreBlank := TRUE;
InCellDropdown := TRUE;
ShowInput := TRUE;
ShowError := TRUE;
END;

Comments

  • DavisDavis Member Posts: 8
    Add finally find solution myself
    You have to add variable:
    XlsValidation Automation 'Microsoft Excel 9.0 Object Library'.Validation

    Change the code:
    .
    .
    .

    XlsValidation := XlsSheet.Range('A1').Validation;
    XlsValidation.Add(3,1,1,TextCustContact);
    .
    .
    .

    All is clear now.
Sign In or Register to comment.