Quantcast
Channel: NAV Three Tier — mibuso.com
Viewing all articles
Browse latest Browse all 10032

Create Word Template

$
0
0
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,

Viewing all articles
Browse latest Browse all 10032

Trending Articles