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

ebitas
Member Posts: 71
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?
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?
0
Answers
-
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.* Daniele Rebussi * | * Rebu NAV Diary *0 -
I have installed a generic text printer with NAV classic 2009 and just print the commands as text. Is this not possible in 2015?0
-
Thanks to all for the help.. I'll try it and let you what I found..
Thanks again oki and geordie0 -
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..0 -
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..0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions