I want to make a macro in Excel2003 that can print a document without open that document first. It's in the same way as print a document from Windows Explorer. Is it possible to make a macro in Excel that can do that?
Explain what you mean by "a document"? If you mean an Excel workbook, can you explain why you want to do this? ( I don't see how that could be possible ... it's not a case of just sending a "file" to the printer ... Excel has to open the file, load it, and then print it .... at least I'm 99% certain that's the way things are )
Cheers, Glenn.
Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
It's not a Excel document. It can be a Word Document but it can also be a PDF document.
It will be OK to open the document first but I hope that it can be printed without open it.
Sorry I have't hear about literalist show-jumper. Sorry
You can set reference to 'Micresoft Shell Controls and Automation' - shell32.dll (or use API shell functions) and use one of build-in dialog to get file and path string. For Acrobat file this prints the file in the same way you do from explorer:
Dim aShell As Shell32.Shell
Dim aFolder As Shell32.Folder
Dim aFile As Shell32.FolderItem
Dim aVerb As Shell32.FolderItemVerb
Set aShell = New Shell32.Shell
Set aFolder = aShell.NameSpace("c:\")
Set aFile = aFolder.ParseName("presentation.pdf")
's = ""
For Each aVerb In aFile.Verbs
' s = s & aVerb.Name & vbCrLf
'Next aVerb
'MsgBox s
aFile.InvokeVerb "print"
There is no universal verb for printing, so the commented code can be used to check proper verb. So is with visibility of application when printing.
Can you set reference to the specified library (in a list on references dialog) or file (references dialog, 'Browse...' button)?
Is the library ticked in references list?
What is the windows version?
The verb string is & (underscore) sensitive, the code does nothing if there is no match.
Hi All
I have given up this. I have found a way to open a document and then print it acording to a calculation in excel. So the people who is going to work with this have to open the document first.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.