Code to print .tif image file from form

S

shoostry343

Hi, Gentlemen!
I am sorry in advance for a long intro.
I am not very familiar with VBA and would greatly appreciate if anyone
could assist me anyhow in solving the following problem.
I need to open and print *.tif image files from MS Access form (using
of other image file type is possible if it does the job).
The task is to print a number of images complementing each other and
referring to a record, on a click of a button. I decided to use
tif-image-type as this is the only image type I know of that can store
more than one image in one file (I could have used a corresponding
folder to store images of one record in, but I do not know how to
programmatically create a folder with a particular name for each
record, and folder-method is not preferred).
I have a code that ideally should work for the type of operation I
need, but it does not work the way it should. I will list the code
below and explain what I have tried to resolve the problem.
If anyone has any ideas on this issue - I would really appreciate any
help or any suggestions.
The code:

Option Compare Database

Private Declare Function apiShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Private Sub PrintImage_Click()
Dim a As Variant
a = Me!StockNumber
Call apiShellExecute(hWndAccessApp, "Print", _
"C:\" & a & ".tif", 0&, 0&, 1)
End Sub


So far I've tried to print into the following programs: Microsoft
Office Document Imaging, Windows Picture and Fax Viewer, Microsoft
Photo Editor, Lexmark Photo Editor. Some of the mentioned programs
opened the files but just did not print and some did not even open even
though all of them open and print fine through direct use.
I also tried to add or edit system actions and application references
in "Edit file type" window of windows file association menu (for
example, MS Office Document Imaging did not have "print" action
assigned therefore it did not react to "print" command from
"ShellExecuteA", but after I added the action the program returned
a critical error).
But nothing worked so far.

If anyone knows of any replacement for "ShellExecuteA" or have any
ideas on how to resolve an issue - please help!
Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top