OBJECT Form 50101 Print Any File { OBJECT-PROPERTIES { Date=16.09.08; Time=13:24:08; Modified=Yes; Version List=NLO; } PROPERTIES { Width=7920; Height=1870; } CONTROLS { { 1101101001;TextBox;3630 ;220 ;4070 ;440 ;CaptionML=[ENU=Select a file; NOR=Velg fil]; SourceExpr=PrintThisFile; OnAssistEdit=BEGIN PrintThisFile := CommonDialogMgt.OpenFile(Text001,'',1,'',0); END; } { 1101101002;Label ;220 ;220 ;3300 ;440 ;ParentControl=1101101001 } { 1101101003;CommandButton;1540;990;2200;550;CaptionML=[ENU=Print File; NOR=Skriv ut fil]; OnPush=BEGIN CREATE(objShell); IF NOT EXISTS(PrintThisFile) THEN EXIT; SplitDirFile(PrintThisFile,Dir,FileName); objFolder := objShell.NameSpace(Dir); objFolderItems := objFolder.Items; objFolderItem := objFolderItems.Item(FileName); objVerbs := objFolderItem.Verbs; i := -1; REPEAT i += 1; IF i < objVerbs.Count THEN objVerb := objVerbs.Item(i); UNTIL (STRPOS(UPPERCASE(objVerb.Name),'PRINT') > 0) OR (i >= objVerbs.Count); IF i <= objVerbs.Count THEN objVerb.DoIt ELSE ERROR(Text002, PrintThisFile); MESSAGE('Ferdig!'); END; } { 1101101005;CommandButton;3960;990;2200;550;PushAction=Close } } CODE { VAR CommonDialogMgt@1101101002 : Codeunit 412; PrintThisFile@1101101013 : Text[250]; Dir@1101101010 : Text[250]; FileName@1101101012 : Text[250]; objShell@1101101001 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{13709620-C279-11CE-A49E-444553540000}:'Microsoft Shell Controls And Automation'.Shell"; Text001@1101101003 : TextConst 'ENU=Select a file...;NOR=Velg fil...'; Text002@1101101004 : TextConst 'ENU=Could not print file %1.\Make sure you use a file extension you can print from Windows Explorer.;NOR=Kunne ikke skrive ut fil %1.\Det er kun mulig † skrive ut filtyper som kan skrives ut fra Windows Explorer.'; objFolder@1101101005 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{BBCBDE60-C3FF-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.Folder"; objFolderItems@1101101006 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{744129E0-CBE5-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.FolderItems"; objFolderItem@1101101007 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{FAC32C80-CBE4-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.FolderItem"; objVerb@1101101011 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{08EC3E00-50B0-11CF-960C-0080C7F4EE85}:'Microsoft Shell Controls And Automation'.FolderItemVerb"; objVerbs@1101101009 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{1F8352C0-50B0-11CF-960C-0080C7F4EE85}:'Microsoft Shell Controls And Automation'.FolderItemVerbs"; i@1101101008 : Integer; PROCEDURE SplitDirFile@1101101000(FullString@1101101000 : Text[250];VAR JustDir@1101101001 : Text[250];VAR JustFileName@1101101002 : Text[250]); VAR ExitLoop@1101101003 : Boolean; PointBreak@1101101004 : Integer; BEGIN ExitLoop := FALSE; PointBreak := STRLEN(FullString); WHILE (NOT ExitLoop) OR (PointBreak <= 1) DO IF COPYSTR(FullString,PointBreak,1) = '\' THEN BEGIN JustFileName := COPYSTR(FullString,PointBreak + 1); ExitLoop := TRUE; END ELSE PointBreak -= 1; JustDir := COPYSTR(FullString,1,PointBreak); END; BEGIN END. } }
Answers
Okey, so I figured out where I had to modify the code to print the file. Now the file prints, but still the properties window of the file is displayed. Also, the file selected for printing is opened, printed, and then automatically closed. It would be better if the user never saw the file during the process.
Can anybody help me? :-k
[/code]