Printing external PDF-files in NAV2009

JanDeBeusscher
Member Posts: 3
I'm looking for a method to print external PDF-files in NAV2009
0
Best Answer
-
You can use this.
OnRun() PrintFile('c:\PASO\Microsoft Dynamics NAV 2009 R2.docx');
PrintFile(Fichero : Text[1024]) IF NOT EXISTS(Fichero) THEN EXIT; CREATE(ObjShell, TRUE); SplitName(FullFileName, Path, _FileName); ObjFolder := ObjShell.NameSpace(Path); ObjFolderItems := ObjFolder.Items; ObjFolderItem := ObjFolderItems.Item(_FileName); ObjVerbs := ObjFolderItem.Verbs; i := -1; total := ObjVerbs.Count; REPEAT i += 1; IF i < total THEN BEGIN ObjVerb := ObjVerbs.Item(i); Nombre := ObjVerb.Name; END; UNTIL (STRPOS(UPPERCASE(ObjVerb.Name), 'PRINT') > 0) OR (i > total); IF i <= total THEN BEGIN ObjVerb.DoIt; END ELSE ERROR('The file %1, can't be printed', _FileName);
// This is the SplitName function SplitName(Fichero : Text[1024];VAR Path : Text[1024];VAR Nombre : Text[1024]) Fichero1 := Fichero; Pos := STRPOS(Fichero1, '\'); Donde := Pos; WHILE Pos <> 0 DO BEGIN Fichero1 := COPYSTR(Fichero1, Pos+1); Pos := STRPOS(Fichero1, '\'); Donde := Donde + Pos; END; Path := COPYSTR(Fichero, 1, Donde); Nombre := COPYSTR(Fichero, Donde+1);
// Automation Vars the rest are Text or Integer ObjShell Automation 'Microsoft Shell Controls And Automation'.Shell ObjFolder Automation 'Microsoft Shell Controls And Automation'.Folder ObjFolderItems Automation 'Microsoft Shell Controls And Automation'.FolderItems ObjFolderItem Automation 'Microsoft Shell Controls And Automation'.FolderItem ObjVerbs Automation 'Microsoft Shell Controls And Automation'.FolderItemVerbs ObjVerb Automation 'Microsoft Shell Controls And Automation'.FolderItemVerb
5
Answers
-
You can use this.
OnRun() PrintFile('c:\PASO\Microsoft Dynamics NAV 2009 R2.docx');
PrintFile(Fichero : Text[1024]) IF NOT EXISTS(Fichero) THEN EXIT; CREATE(ObjShell, TRUE); SplitName(FullFileName, Path, _FileName); ObjFolder := ObjShell.NameSpace(Path); ObjFolderItems := ObjFolder.Items; ObjFolderItem := ObjFolderItems.Item(_FileName); ObjVerbs := ObjFolderItem.Verbs; i := -1; total := ObjVerbs.Count; REPEAT i += 1; IF i < total THEN BEGIN ObjVerb := ObjVerbs.Item(i); Nombre := ObjVerb.Name; END; UNTIL (STRPOS(UPPERCASE(ObjVerb.Name), 'PRINT') > 0) OR (i > total); IF i <= total THEN BEGIN ObjVerb.DoIt; END ELSE ERROR('The file %1, can't be printed', _FileName);
// This is the SplitName function SplitName(Fichero : Text[1024];VAR Path : Text[1024];VAR Nombre : Text[1024]) Fichero1 := Fichero; Pos := STRPOS(Fichero1, '\'); Donde := Pos; WHILE Pos <> 0 DO BEGIN Fichero1 := COPYSTR(Fichero1, Pos+1); Pos := STRPOS(Fichero1, '\'); Donde := Donde + Pos; END; Path := COPYSTR(Fichero, 1, Donde); Nombre := COPYSTR(Fichero, Donde+1);
// Automation Vars the rest are Text or Integer ObjShell Automation 'Microsoft Shell Controls And Automation'.Shell ObjFolder Automation 'Microsoft Shell Controls And Automation'.Folder ObjFolderItems Automation 'Microsoft Shell Controls And Automation'.FolderItems ObjFolderItem Automation 'Microsoft Shell Controls And Automation'.FolderItem ObjVerbs Automation 'Microsoft Shell Controls And Automation'.FolderItemVerbs ObjVerb Automation 'Microsoft Shell Controls And Automation'.FolderItemVerb
5 -
Sorry this line:
SplitName(FullName, Path, _FileName);
Must be like thisSplitName(Fichero, Path, _FileName);
0 -
IF RTC THEN
https://juhl.blog/2017/04/15/first-blog-post/
Call a pdf reader that has print silent parameters.Follow me on my blog juhl.blog0 -
[Topic moved from 'Navision Attain' forum to 'NAV/Navision Classic Client' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi, I know this is a really old one, but I need this for a customer with NAV 2009.
I get a C/AL Error on execution of the code with this line:ObjVerbs := ObjFolderItem.Verbs;
The error say "No Instance created for the Automation".
Any idea why?0 -
0
-
The reason is probably that the item (path or file) is not found or "you" do not have access to the file. (Don't know whether "you" is the user executing this, or the service tier user in case this is run on the NST.)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