Printing notepad file using SHELL

nnohrnnohr Member Posts: 18
Hi,

I would like to print a notepad file from NAV. I can print the file, but I do not want it displayed on the screen that notepad open and print the file.

My command:
param := 'C:\Program Files\NNIT\DKEXE 6.0 A Development\DKEXE.BON';
SHELL("C:\Windows\System32\notepad.exe",STRSUBSTNO('/p "%1"',param));

Can anyone help med?

Thank you in advance.

Comments

  • ebsoftebsoft Member Posts: 81
    Once I used this command:
    SHELL('copy simple.txt LPT1:');
    
    But only onto old versions.

    What version are you using?
    Regards,
    Federico

    MBS Specialist since NAV 2.0
    My experiences on Linkedin
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Or you can open the command promt and send below command
    'notepad /p '+ '<your txt file path>'
    
  • vaprogvaprog Member Posts: 1,141
    You could use the Run-method of the 'Windows Script Host Object Model'.WshShell Automation type, but Notepad will show a message box where the user can abort the printing anyway.
  • nnohrnnohr Member Posts: 18
    ebsoft wrote:
    Once I used this command:
    SHELL('copy simple.txt LPT1:');
    
    But only onto old versions.

    What version are you using?

    Hi ebsoft,

    I'm using Nav2009SP1. I get an error when I run it, that some characters are invalid, I think that is characters from path to the file.
  • nnohrnnohr Member Posts: 18
    Or you can open the command promt and send below command
    'notepad /p '+ '<your txt file path>'
    


    Hi mohana_cse06,

    I have tested with command prompt and it "works". The problem is, that it is after posting a sales order and after calling command prompt, I got an error, that the sales order cannot be found - probably because it has been posted.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    I guess you are writing in wrong place..

    Where did you write the code?
  • nnohrnnohr Member Posts: 18
    I guess you are writing in wrong place..

    Where did you write the code?

    I made a box solution where I need to print a file immediately after posting a in Navision. It must occur after posting, but if I do, then there are problems because another program is called to print the file.
Sign In or Register to comment.