Enclosing a single quote within single quotes

asmilie2b3asmilie2b3 Member Posts: 39
I have an issue, where I need to put a single quote ' into C/AL, but not have it read as a close/start of a string.
I am exporting a report to excel with the excel buffer. All I need to do is enter a formula of a cell to reference another one. the problem is that the other cell I need to reference is on another sheet. So in excel the formula of the cell needs to be:

='AUC00232'!G35

(AUC00232 is the name of the other sheet).
So Excell needs the ' in the start and end of the sheet name, but NAV reads it as the first one as the start of a string and it throws the error below when trying to compile:

')' should come here.

Below is the code I am using. I was sure I read perhaps on Mibuso I could use to single quotes ('') and NAV would treat that as one. Could someone refresh my memory on how to do this as darned if I can find it from searching the forum..

xlsInsertCell(xRow,xCol,TmpStr := '=''' + Customer."No." = '''!' + LcyTotCell,TRUE,FALSE,FALSE,'','');

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    You'll have to use 2 times the ' character to get one ' character in your output.
    Try this
    MESSAGE('%1','=''AUC00232''!G35');
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • asmilie2basmilie2b Member Posts: 122
    Hello Luc,

    Many thanks for answering my trivial question. You are of course correct.
    What I needed was in total 3 quotes:

    xlsInsertCell(xRow,xCol,'=''' + FORMAT(Customer."No.") + '''!' + LcyTotCell,TRUE,FALSE,FALSE,'','');

    Bruce Anderson
  • creigleecreiglee Member Posts: 1
    generally when u deal with apostrophe
    u replace the the single quote(')
    with ('').

    More about....handling single quotes

    Antonio
Sign In or Register to comment.