Hi
I am looking at writing a function that takes a filename as parameter. This function would then print the file as setup in the registry for that particular file type. (These types are setup under Folder options, File Types)
Is there an easy way of doing this?
Any help appreciated.
Cheers
Detlef
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I have a blob field, which contains a file (extension can be a number of things). I would like to print this file to a pdf file and send through email.
I think the solution is to make a print-procedure for every possible extension (.doc, .xls, .pdf, ...).
any suggestions?
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
I did not test it, I only found it on google... may be that there is some interface to this or some similar application...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
- Export BLOB field to file name (extension is in attachment table).
- validate extension:
- if .doc: use word automation
- if .xls: use excel automation
- if .mpp: use project automation
- ...
- convert to pdf with amyuni
- open mail message with pdf document
may be not the best way to do it, but it works like a charm!
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Peter
You notice that when you right click on different files in explorer, sometimes you get the "print" functionality, sometimes you don't get it. So it depends on the filetype whether you can print the file or not.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
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);
This works fine. But now I have the next problem:
What I want to do is print several files into one PDF file using Amyuni and then email the file.
objVerb.DoIt; will do the printing but it does it asynchronus.
I need to find a way to find out when the printing is finished so I can pick up the pdf file and attach it to an email.
If I put a sleep(5000) command after all the PrintFile calls it actually delays the printing.
The only way I can think of is using the timer and check if the datetime on the file has not changed in x seconds. I hate using the timer! it stuffs up debugging.
Anybody got any ideas?
Cheers
Detlef
Did you find a solution to the problem?
Peter
Anyone taken this any farther?
Bell Business Solutions
Calgary, NB, CANADA
darren.bezzant@bell.ca
Thanks
Unfortunatly the solution is not language independant (or even setup independant).
So the only warning I could give is go to the file you want to print, right click it and see if you which command you can use to print it. Replace the 'PRINT' text in the code with the command specified.
Nevertheless thank you!
|To-Increase|
PrintThisFile := 'D:\Terms.pdf';
IF ISCLEAR(objShell) THEN
CREATE(objShell);
SplitDirFile(PrintThisFile,Dir,FileName);
objFolder := objShell.NameSpace(Dir);
objFolderItems := objFolder.Items;
objFolderItem := objFolderItems.Item(FileName);
objFolderItem.InvokeVerb('PRINT');
objVerbs := objFolderItem.Verbs;
Awaiting for the responses. Thank u all in advance..
Falling down is not a defeat..defeat is when you refuse to get up.
with (Untested - it just seemed wrong)
Edit: Not true - my bad...
Peter
Any idea resolving the same would be very thankful..
Awaiting for the reply.
Falling down is not a defeat..defeat is when you refuse to get up.
But that leads to the next problem. I guess you are not using an English PDF reader, and therefore the menu-item in the pdf-file context-menu-item does not contain "PRINT". In my case I had to change it to "UDSKRIV" which is Danish for PRINT.
The reason for your code showing the Properties window, is that it is the last menu-item. My original suggestion should prevent that, but then you just get the error below :?
I'll suggest you add this line to troubleshoot: just before the UNTIL line...
There doesn't seem to be a language independent solution to this problem, so you will need some way to determine which text to look for at the specifik users setup. It could be different for each file-extension for each user. ](*,)
Peter