Options

instream error when word download

tsodartsodar Member Posts: 21
Hello, I have functionality which in old NAV I could export word and open it with the following code

Table1.SETRANGE("Mark for Printing", TRUE);
Table1.SETRANGE("SayYes", FALSE);
IF Table1.FIND('-') THEN REPEAT
_servertempFileName := _FileMgt.ServerTempFileName('DOCX');
_clienttempFileName := _FileMgt.ClientTempFileName('DOCX');
Table2.SETRANGE(ID,Table1.ID);
REPORT.SAVEASWORD(Table1Setup."Report 1",_servertempFileName,Table2);
_FileMgt.DownloadToFile(_servertempFileName, _clienttempFileName);
_FileMgt.DeleteServerFile(_servertempFileName);
HYPERLINK(_clienttempFileName);
UNTIL _C062FitaxData.NEXT = 0;


Table1.SETRANGE(SayYes, TRUE);
IF Table1.FIND('-') THEN REPEAT
_servertempFileName := _FileMgt.ServerTempFileName('DOCX');
_clienttempFileName := _FileMgt.ClientTempFileName('DOCX');
Table2.SETRANGE(ID,Table1.ID);
REPORT.SAVEASWORD(Table1Setup."Report 2",_servertempFileName,Table2);
_FileMgt.DownloadToFile(_servertempFileName, _clienttempFileName);
_FileMgt.DeleteServerFile(_servertempFileName);
HYPERLINK(_clienttempFileName);
UNTIL Table1.NEXT = 0;
but was getting "Sorry, this action is unavailable..."


I have the following code in AL


Table1.SetRange("Mark for Printing", true);
Table1.SetRange("NZ Template", false);
if Table1.Find('-') then
repeat

servertempFileName := FileMgt.ServerTempFileName('DOCX');
clienttempFileName := FileMgt.ClientTempFileName('DOCX');

ToFileName := servertempFileName + '.txt';

Table2.SetRange(ID, Table1.ID);
REPORT.SaveAsWord(Table1Setup.SayYes, servertempFileName, Table2);


DownloadFromStream(NewStream, 'Export', servertempFileName, 'All Files (*.*|*.*)', ToFileName);
until Table1.Next = 0;


Table1.SetRange("SayYes", true);
if Table1.Find('-') then
repeat

ToFileName := servertempFileName + '.txt';
servertempFileName := FileMgt.ServerTempFileName('DOCX');
clienttempFileName := FileMgt.ClientTempFileName('DOCX');
Table2.SetRange(ID, Table1.ID);
REPORT.SaveAsWord(Table1Setup."Report 2", servertempFileName, Table2);
REPORT.SAVEASPDF(Table1Setup."Report 2", servertempFileName, Table2);
FileMgt.DownloadToFile(servertempFileName, clienttempFileName);
FileMgt.DeleteServerFile(servertempFileName);
HyperLink(clienttempFileName);
DownloadFromStream(NewStream, 'Export', servertempFileName, 'All Files (*.*|*.*)', ToFileName);
until Table1.Next = 0;

but now am getting this NAV.InstreamVariable not initialised

WHat am I missing?
Sign In or Register to comment.