Error in calling XlWrkSht.Shapes

WLWL Member Posts: 12
Hi,

Does anyone know why

XlWrkSht.Shapes.AddPicture('c:\test.bmp', 1, 1, 20, 20, 100, 100);

will give me the error

"Could not invoke the member Shapes. The OLE Control or Automation server returned the following message: The requested member does not exist, or the call tried to set the value of a read-only property."

I am able to see Shapes when I am at the C/AL Symbol Menu

How to resolve this error?

Thanks,
WL

Comments

  • AlbertvhAlbertvh Member Posts: 516
    Hi

    I have used this coding with success
    RowNo := 1;
    ColumnNo := 1;
    Range := GetColumnStr(1) + FORMAT(RowNo);
    Sheet.Range(Range).Select;
    Sheet.Range(Range).Activate;
    Sheet.Shapes.AddPicture(ENVIRON('TEMP') + '\Logo.bmp',1,1,0,0,150,50);
    

    where Sheet is variable of subtype 'Microsoft Excel 11.0 Object Library'.Worksheet

    Also check that the sheet is active using

    CLEAR(App);
    CREATE(App);
    App.Visible(FALSE);
    Book := App.Workbooks.Add(-4167);


    Book.Worksheets.Add;

    Sheet := App.ActiveSheet;

    Hope this helps


    Albert
  • WLWL Member Posts: 12
    Hi Albert,

    I have created a function in the Exel Buffer Table.
    The function contains the following coding:

    createbook;
    XlWrkSht.Shapes.AddPicture('c:\test.bmp', 1, 1, 20, 20, 100, 100);

    I did not copy exactly your coding as there isn't any GetColumnStr

    I have check that the subtype is 'Microsoft Excel 11.0 Object Library'.Worksheet

    Now I am getting 'Excel not found'.

    Please advice.

    Thanks,
    WL
  • AlbertvhAlbertvh Member Posts: 516
    Hi WL

    instead of getcolumnstr use GetColumnID in the buffer table
    and replace Sheet by XlWrkSht in the coding.


    Albert
  • WLWL Member Posts: 12
    Hi Albert,

    Thanks. I can get in working now. :)

    However, I have another problem. Currently, I am export inga report to an excel. I need to export an image which is at the footer of the report. How should the paramaters be written in the AddPicture? I do not know the XPOS and YPOS Position due to I have no ideas how many details will be generated.

    Thanks,
    WL
  • AlbertvhAlbertvh Member Posts: 516
    Hi WL

    Are you printing each header of the report into theexcel file?
    I think you will have to play around with the first 2 parameters

    Sheet.Shapes.AddPicture(ENVIRON('TEMP') + '\Logo.bmp',1,1,0,0,150,50);

    The 1,1 in the above statement are the row and column numbers (I can't remeber :roll: )


    Albert
  • WLWL Member Posts: 12
    Hi Albert,

    Yes, I am printing whatever shown on the report out to excel.

    Finally, I have gotten everything working. Thanks alot.

    WL
  • AlbertvhAlbertvh Member Posts: 516
    Glad I could help


    Albert
Sign In or Register to comment.