Options

How to Send a text file to Zebra Printer in Nav 2015?

ebitasebitas Member Posts: 71
edited 2015-02-10 in NAV Three Tier
I use Zebra Printer to Print 2D Bar code lables. In Native Navision in the code I create and save the file in my hard drive then I use a shell command to send the file to the printer and have it print 2D Bar code:

LabelFileName := '\\SAM-THINK\E\' + "Bearing Bar Order"."Document No." + '.txt';
ReturnCode := SHELL(ENVIRON('COMSPEC'),'/c type ' + LabelFileName + ' > LPT1');

The SHELL command is no longer valid in NAV 2015 RTC!! How can I communicate with the Printer? How can I send the text file to the Zebra printer so It will print 2D Bar Codes?

The Zebra Printer is a USB Printer.

Any Help?

Answers

  • Options
    geordiegeordie Member Posts: 655
    edited 2015-02-06
    SHELL command must be replaced with DotNet interoperability, something like this:
    Name	DataType	Subtype
    environment	DotNet	System.Environment.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
    WShell	DotNet	System.Diagnostics.Process.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
    ProcInfo	DotNet	System.Diagnostics.ProcessStartInfo.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
    
    LabelFileName := '\\SAM-THINK\E\' + "Bearing Bar Order"."Document No." + '.txt';
    
    ProcInfo := ProcInfo.ProcessStartInfo;
    ProcInfo.FileName := environment.GetEnvironmentVariable('COMSPEC');
    ProcInfo.Arguments := LabelFileName;
    ProcInfo.UseShellExecute := FALSE;
    ProcInfo.RedirectStandardOutput := TRUE;
    ProcInfo.WindowStyle := 1; // Hidden
    ProcInfo.CreateNoWindow := TRUE; 
    
    WShell:= WShell.Start(ProcInfo);
    WShell.WaitForExit;
    

    Not sure if it's the right syntax, I haven't upgrated a Zebra implementation yet.
  • Options
    okioki Member Posts: 46
    Have a look right here.

    Oli
  • Options
    mdPartnerNLmdPartnerNL Member Posts: 802
    I have installed a generic text printer with NAV classic 2009 and just print the commands as text. Is this not possible in 2015?
  • Options
    ebitasebitas Member Posts: 71
    Thanks to all for the help.. I'll try it and let you what I found..

    Thanks again oki and geordie
  • Options
    ebitasebitas Member Posts: 71
    The issue has been resolved by modifying the code as follow:

    Name DataType Subtype
    wSHShell Automation 'Windows Script Host Object Model'.WshShell


    IF ISCLEAR(wSHShell) THEN BEGIN
    CREATE(wSHShell,FALSE,ISSERVICETIER);
    wSHShell.Run('cmd.exe /C type ' + LabelFileName + ' > LPT1');
    CLEAR(wSHShell);
    END;


    Thanks to all who replied to my post and helped me..
  • Options
    ebitasebitas Member Posts: 71
    The issue has been resolved by modifying the code as follow:

    Name DataType Subtype
    wSHShell Automation 'Windows Script Host Object Model'.WshShell

    IF ISCLEAR(wSHShell) THEN BEGIN
    CREATE(wSHShell,FALSE,ISSERVICETIER);
    wSHShell.Run('cmd.exe /C type ' + LabelFileName + ' > LPT1');
    CLEAR(wSHShell);
    END;

    Thanks to all who replied to my post and helped me..
Sign In or Register to comment.