Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel print

Status
Not open for further replies.

alring

Technical User
Nov 11, 2005
18
DK
Hi there

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?

Best regards
Mads
 
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.
 
Hi Gleen

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.

combo
 
Hi combo

I have tried what you said. But Excel don't accept the code you wrote. And I have to use Excel.

Best regards
Mads
 
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.

combo
 
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.

Best regards
Mads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top