Printout “C\xxxx\xxxxx.pdf”

sahersite

New member
Local time
Today, 06:29
Joined
Dec 20, 2006
Messages
8
Hi,

Can you please help?

I would like to write a code to issue a print command at certain path for example

Printout “C\xxxx\xxxxx.pdf”

I tried hard here and every where in the net, can’t find anything??

thanks in advance.
 
How is the path determined? Is someone going to type in the path into a textbox? Is it a stored value in table? Are you wanting them to select it via a dialog box? What...?
 
All I need is how to issue a print command for existing files

I have scanned documents as pdf , I have the serial number of all documents in a table so I want to issue a command for a print with loop
All I need is how to issue a print command for existing files for example
I have myphoto.pdf in my “C:\MyDocument” folder
So my code should be

Dim MyPath as String

MyPath = “My c:\MyDocument\MyPhoto.pdf”

Printout.Mypath

Or something like that.

Thanks in advance,
 
If the issue is to print some kind of file, then I'd look at the ShellExecute API, which is usually used to open a document in the program registered to that file type. Passing "Print" in stead of the default "Open" as the second arguement, should make it print. See http://allapi.mentalis.org/apilist/ShellExecute.shtml for more info
Code:
' in the declaration section of the form
Private Declare Function ShellExecute 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

' couple extra constants
Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3

Private Sub SomeSub()
    ' - lifted from 'URL: http://www.allapi.net/
    ShellExecute Me.hwnd, "Print", "c:\MyFolder\MyFile.pdf", _
                      vbNullString, vbNullString, SW_HIDE
End Sub
You might probably see the Adobe program "flash" a bit, perhaps it'll stay open afterwards, but it should should print. For a wrapper function, which will also prompt if you try to print files that aren't associated with any application, you might have a look at this
 
it works

:) Thank you very much. you really helped me. I appreciate it.

But one more thing, can I change the printer even is is not the default one and can I choose the number of sets (copies), I tried the following,


Dim prtDefault As Printer, Prn As Printer, Rpt As String
Set Application.Printer = Application.Printers("Canon iR5570/iR6570 PCL5e")

Set prtDefault = Application.Printer
With prtDefault
.Copies
End With

And so on, but it did not work properly

Thanks in advance,
 
This I don't know, but my thought is that if using the API, we send the print command to the application associated with the file we're passing the path to, which pretty much leaves that application in command. With the Application.Printers method, I think we can alter which printer Access prints the next object to, but I doubt it influences other applications.

I don't know how to do that, except when using programs I can automate from Access. For the number of copies, I think you could just call the code the number of times you need a copy.

A quick search, revealed that Randy Birch has code to change default printers
http://vbnet.mvps.org/index.html?code/system/defaultprinter.htm
http://vbnet.mvps.org/index.html?code/system/setdefaultprinter.htm

His code is for Classic VB (VB 5/6), so not all will work "copy/pasted" to Access/VBA.
 

Users who are viewing this thread

Back
Top Bottom