Activate Excel Workbook

MMaier1MMaier1 Member Posts: 5
Hello, I'm trying to insert a picture in an Excel File and I found Shapes.AddPicture. But I had a problem before, when i try to activate the WorkSheet

dkh228nct5jc.jpg

My code is:

j4svuplap6pb.jpg

Where am I doing wrong?

Thanks

Answers

  • KishormKishorm Member Posts: 921
    Where is it erroring in the code?
    Activate the debugger and show us where it stops.
  • MMaier1MMaier1 Member Posts: 5
    xlWrkBk is null: xlApp.ActiveWorkbook doesn't active xlWrkBk and I don't understand the reason :(
  • KishormKishorm Member Posts: 921
    You're just opening the Excel Application - there is no current workbook. I think you need to open a workbook or create one
  • MMaier1MMaier1 Member Posts: 5
    I'm using Excel Buffer table and I thought workbook was still activated, but it doesn't seem
  • TiwazTiwaz Member Posts: 98
    edited 2016-11-23
    To open workbook and later use dotnet, you must use OpenBookDotNet custom function in ExcelBuffer table which looks something like this:

    ClientTempFileName := ThreeTierMgt.ClientTempFileName(PathRTC.GetExtension(FileName));
    FileRTC.Copy(FileName, ClientTempFileName);
    UPLOADINTOSTREAM('',ThreeTierMgt.Magicpath,'',ClientTempFileName,NVInStream);
    MemoryStream := NVInStream;


    XlWrkBkDotNet := XlWrkBkDotNet.XLWorkbook(MemoryStream);
    i := 1;
    EndOfLoop := XlWrkBkDotNet.Worksheets.Count;
    WHILE (i <= EndOfLoop) AND (NOT Found) DO BEGIN
    XlWrkshtsDotNet := XlWrkBkDotNet.Worksheet(i);
    IF SheetName = XlWrkshtsDotNet.Name THEN
    Found := TRUE;
    i := i + 1;
    END;
    IF Found THEN
    XlWrkShtDotNet := XlWrkBkDotNet.WorksheetString(SheetName)
    ELSE BEGIN
    CLEAR(XlWrkBkDotNet);
    END;
    For DotNet Variables XlWrkShtDotNet, XlWrkBkDotNet etc, you need to use ClosedXML.Excel.XLWorkbook assemblies
Sign In or Register to comment.