Can anyone help me with Automatically printing Record Links? This means that the file in the record link's URL will need to be called and automatically printed without the user having to do anything except posting.
//The following Function is using Automation Objects from 'Microsoft Shell Controls And Automation' (Shell32).
PrintFile( FileName : Text[250])
CREATE(objShell);
IF NOT EXISTS(FileName) THEN
EXIT;
SplitDirFile(FileName,Dir,File);
objFolder := objShell.NameSpace(Dir);
objFolderItems := objFolder.Items;
objFolderItem := objFolderItems.Item(File);
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 BEGIN
objVerb.DoIt;
END ELSE
ERROR('Could not print file %1\Make sure you use a file extension you can print from Windows Explorer', FileName);
hello, is this useful if i want to make a report that prints for example a list of items?
i have 3000 items and a high quality picture in the record link of each item.
i now want to create a report with a picture box that has this jpeg-image.
I have refloated this post because i want to use this function but i have a lot of questions...
PrintFile( FileName : Text[250])
CREATE(objShell); --> I think the subtype is 'Microsoft Shell Controls And Automation'.Shell???
IF NOT EXISTS(FileName) THEN
EXIT;
SplitDirFile(FileName,Dir,File); --> Is this a function? Why? And the parameteres?
objFolder := objShell.NameSpace(Dir); --> --> I think the subtype is 'Microsoft Shell Controls And Automation'.Folder
objFolderItems := objFolder.Items; --> --> I think the subtype is 'Microsoft Shell Controls And Automation'.FolderItems
objFolderItem := objFolderItems.Item(File); --> --> I think the subtype is 'Microsoft Shell Controls And Automation'.FolderItem???
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 BEGIN
objVerb.DoIt;
END ELSE
ERROR('Could not print file %1\Make sure you use a file extension you can print from Windows Explorer', FileName);
SplitDirFile(FullString : Text[250];VAR JustDir : Text[250];VAR JustFileName : Text[250])
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);
Funcion 2: PrintFile Variables LocalesName DataType Subtype Length
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
Dir Text 250
Filename Text 250
PrintFile(PrintThisFile : Text[250])
IF ISCLEAR(objShell) THEN
CREATE(objShell);
IF NOT EXISTS(Filename) THEN
EXIT;
SplitDirFile(PrintThisFile,Dir,Filename);
objFolder := objShell.NameSpace(Dir);
objFolderItems := objFolder.Items;
objFolderItem := objFolderItems.Item(Filename);
objFolderItem.InvokeVerb('PRINT');
objVerbs := objFolderItem.Verbs;
i:=-1;
REPEAT
i+=1;
IF iobjVerb := objVerbs.Item(i);
UNTIL (STRPOS(UPPERCASE(objVerb.Name),'PRINT')>0) OR (i >=objVerbs.Count);
IF i<=objVerbs.Count THEN BEGIN
objVerb.DoIt;
END ELSE
ERROR('Could not print file %1\Make sure you use a file extension you can print from Windows Explorer', FileName);
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Source: http://www.mibuso.com/forum/viewtopic.php?t=7293
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
i have 3000 items and a high quality picture in the record link of each item.
i now want to create a report with a picture box that has this jpeg-image.
is this possible?
PrintFile( FileName : Text[250])
CREATE(objShell); --> I think the subtype is 'Microsoft Shell Controls And Automation'.Shell???
IF NOT EXISTS(FileName) THEN
EXIT;
SplitDirFile(FileName,Dir,File); --> Is this a function? Why? And the parameteres?
objFolder := objShell.NameSpace(Dir); --> --> I think the subtype is 'Microsoft Shell Controls And Automation'.Folder
objFolderItems := objFolder.Items; --> --> I think the subtype is 'Microsoft Shell Controls And Automation'.FolderItems
objFolderItem := objFolderItems.Item(File); --> --> I think the subtype is 'Microsoft Shell Controls And Automation'.FolderItem???
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 BEGIN
objVerb.DoIt;
END ELSE
ERROR('Could not print file %1\Make sure you use a file extension you can print from Windows Explorer', FileName);
And finally, when you print the document?
Can somebody help me with these questions?
It doesn´t show any error but it doesn´t print!!! ](*,)
Funcion 1: SplitDirFile
Valiables locales:Name DataType Subtype Length
PointBreak Integer
ExitLoop Boolean
SplitDirFile(FullString : Text[250];VAR JustDir : Text[250];VAR JustFileName : Text[250])
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);
Funcion 2: PrintFile
Variables LocalesName DataType Subtype Length
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
Dir Text 250
Filename Text 250
PrintFile(PrintThisFile : Text[250])
IF ISCLEAR(objShell) THEN
CREATE(objShell);
IF NOT EXISTS(Filename) THEN
EXIT;
SplitDirFile(PrintThisFile,Dir,Filename);
objFolder := objShell.NameSpace(Dir);
objFolderItems := objFolder.Items;
objFolderItem := objFolderItems.Item(Filename);
objFolderItem.InvokeVerb('PRINT');
objVerbs := objFolderItem.Verbs;
i:=-1;
REPEAT
i+=1;
IF iobjVerb := objVerbs.Item(i);
UNTIL (STRPOS(UPPERCASE(objVerb.Name),'PRINT')>0) OR (i >=objVerbs.Count);
IF i<=objVerbs.Count THEN BEGIN
objVerb.DoIt;
END ELSE
ERROR('Could not print file %1\Make sure you use a file extension you can print from Windows Explorer', FileName);
Whyyyyyyy I can´t print? ](*,) ](*,)