轉:http://download.csdn.net/source/876883
Delphi+Codesoft 7.0 調用條碼格式文件打印
procedure TFormMain.btnPrintClick(Sender: TObject);
Var
s: string;
i : Integer;
BarApp,BarDoc,BarVars:Variant; // OLE 變量
Begin
if not FileExists(edtBClabelName.Text) then
begin
stat.Panels[2].Text := 'The Barcode Document is not Exists.';
ShowMessage('The Barcode Document is not Exists.');
Exit;
btnOpen.SetFocus;
end;
BarApp := CreateOleObject('lppx.Application');
//arApp.Visible:=True;
BarApp.Visible:=False;
BarDoc:=BarApp.ActiveDocument;
BarVars:=BarDoc.Variables;
BarDoc.Open(edtBClabelName.Text);
// 變量賦值
if chkParam.Checked then
begin
BarDoc.Variables.Item('var1').Value:= edtPN.Text;
BarDoc.Variables.Item('var2').Value:= edtPartName.Text;
BarDoc.Variables.Item('var3').Value:= edtDesc.Text;
end;
// 打印標簽
Bardoc.Printlabel(seqty.Value);
// Feed
BarDoc.FormFeed;
// 關閉
Bardoc.Close;
BarApp.Quit;
End;
如果報Undeclare identified 'CreateOleObject' 錯誤, 則引入ComObj 即可
Delphi+Codesoft 7.0 調用條碼格式文件打印
procedure TFormMain.btnPrintClick(Sender: TObject);
Var
s: string;
i : Integer;
BarApp,BarDoc,BarVars:Variant; // OLE 變量
Begin
if not FileExists(edtBClabelName.Text) then
begin
stat.Panels[2].Text := 'The Barcode Document is not Exists.';
ShowMessage('The Barcode Document is not Exists.');
Exit;
btnOpen.SetFocus;
end;
BarApp := CreateOleObject('lppx.Application');
//arApp.Visible:=True;
BarApp.Visible:=False;
BarDoc:=BarApp.ActiveDocument;
BarVars:=BarDoc.Variables;
BarDoc.Open(edtBClabelName.Text);
// 變量賦值
if chkParam.Checked then
begin
BarDoc.Variables.Item('var1').Value:= edtPN.Text;
BarDoc.Variables.Item('var2').Value:= edtPartName.Text;
BarDoc.Variables.Item('var3').Value:= edtDesc.Text;
end;
// 打印標簽
Bardoc.Printlabel(seqty.Value);
// Feed
BarDoc.FormFeed;
// 關閉
Bardoc.Close;
BarApp.Quit;
End;
如果報Undeclare identified 'CreateOleObject' 錯誤, 則引入ComObj 即可