OBJECT Codeunit 50002 Print Any File { OBJECT-PROPERTIES { Date=04/24/09; Time=[ 3:14:54 PM]; Modified=Yes; Version List=FJL; } PROPERTIES { OnRun=BEGIN END; } CODE { PROCEDURE PrintAnyFile@1000000000(VAR FilePath@1000000011 : Text[250];VAR DIR@1000000012 : Text[250];VAR FileName@1000000013 : Text[250]); VAR Ret@1000000009 : Integer; CommonDialogMgt@1000000008 : Codeunit 412; PrintThisFile@1000000007 : Text[250]; ObjShell@1000000004 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{13709620-C279-11CE-A49E-444553540000}:'Microsoft Shell Controls And Automation'.Shell"; objVerbs@1000000003 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{1F8352C0-50B0-11CF-960C-0080C7F4EE85}:'Microsoft Shell Controls And Automation'.FolderItemVerbs"; objFolder@1000000002 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{BBCBDE60-C3FF-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.Folder"; objFolderItems@1000000001 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{744129E0-CBE5-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.FolderItems"; objFolderItem@1000000000 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{FAC32C80-CBE4-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.FolderItem"; Text000L@1000000010 : TextConst 'ENU=Couldn''''t find the file %1.\Please check that the path and filename is correct.'; BEGIN // FILEPATH = WHOLE FILE PATH (C:/DRIVE/FOLDERS/SUBFOLDERS/EXAMPLE.DOC) // DIR = DIRECTORY LIST OF FILE PATH ONLY (C:/DRIVE/FOLDERS/SUBFOLDERS/ ) // FILENAME = FILE NAME ONLY (EXAMPLE.DOC) IF ISCLEAR(ObjShell) THEN CREATE(ObjShell); IF NOT EXISTS(FilePath) THEN ERROR(Text000L,FilePath); objFolder := ObjShell.NameSpace(DIR); objFolderItems := objFolder.Items; objFolderItem := objFolderItems.Item(FileName); objFolderItem.InvokeVerb('PRINT'); objVerbs := objFolderItem.Verbs; END; BEGIN END. } }
Comments
In order to close word, you will have to create a automation to this.
The way you have done it, opens any document in the program which you chose for the type of documents.
You can see in codeunit, Attachment Managment i think, how to open word with a given file.
About the Printer and printer tray, i haven't seen any with such functionality. My best guess would be the word Automation.
Best Regards
René Ravn
Somehow - when the code runs on the client's system - they don't experience this problem. SO...I guess word closing is a dead issue now.
However - I do still need to know if there's a slick way to set the printer for these documents that are printing from the MS Shell automation "print" verb.
Any ideas anyone???
Did you found a solution to the printer selection within the MS Shell Automation ?
L