Hi to all,
I'm trying to create a word template for every "Item Service Group" . Here is the code:
SalesShipmentLineTemp.RESET;
IF SalesShipmentLineTemp.FINDSET THEN
REPEAT
Item.GET(SalesShipmentLineTemp."No.");
IF ServiceItemGroup.GET(Item."Service Item Group") THEN ;
ServiceItemGroup.TESTFIELD(ServiceItemGroup."Warranty File");
CREATE(wdApp,FALSE,TRUE);
TemplateName:='C:\Warranty\Customers\';
TemplateName:=TemplateName+ServiceItemGroup."Warranty File";
wdDoc:=wdApp.Documents.Add(TemplateName);
wdApp.ActiveDocument.Fields.Update;
ItemDescription:=DELCHR(Item.Description+','+Item."No.",'<',' ');
wdRange := wdApp.ActiveDocument.Fields.Item(1).Result;
wdRange.Text := ItemDescription;
BrendCode:='';
IF DefaultDim.GET(27,SalesShipmentLineTemp."No.",'AD') THEN
BrendCode:=DefaultDim."Dimension Value Code";
wdRange:=wdApp.ActiveDocument.Fields.Item(2).Result;
wdRange.Text:=BrendCode;
wdRange:=wdApp.ActiveDocument.Fields.Item(3).Result;
wdRange.Text:=SalesShipmentLineTemp.Description;
wdRange:=wdApp.ActiveDocument.Fields.Item(4).Result;
wdRange.Text:=SalesShipHdr."Ship-to Name";
ServiceItemGroup.GET(Item."Service Item Group");
wdRange:=wdApp.ActiveDocument.Fields.Item(5).Result;
wdRange.Text:=COPYSTR(FORMAT(ServiceItemGroup."Default Warranty Duration"),1,STRLEN(FORMAT(ServiceItemGroup."Default Warranty Duration"))-1);
wdApp.Visible:=TRUE;
CLEAR(wdApp);
UNTIL SalesShipmentLineTemp.NEXT=0;
I just get the first word doc, and after that I got this error:
"Call was rejected by callee. (Exception from HRESULT: 0x80010001(RPC_E_CALL_REJECTED))."
Any advice,
Thanks a lot,
0
Answers
Your word file may be in use. If you create a new file with same name it will solve the error. It may be because the file takes too long to open or something is corrupt. If this does not work, try adding SLEEP(Duration) to give it time to open but this is a long shot
Or it may be because you are not using licensed Word. Hope it helps