INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Print an OLE object

Print an OLE object

(OP)
How can I print an OLE object document?

I have tried ('Office' is an unbound OLE frame)

CODE

Set oDoc = Me.Office.Object.Application
oDoc.PrintOut Background:=False 

That just errors with

Quote:

This method or property is not available because this document is being edited in another application

So I tried it when the document isn't 'activated' but that errors with

Quote:

Automation Error : The object invoked has disconnected from it's clients.

This KB : https://support.microsoft.com/en-us/kb/210030

Shows what I'm already doing other than the verb being Open and I'm using Show.

Why can't I print the word document from the OLE object?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Print an OLE object

(OP)
Well it seems it is impossible to print an active document that is open via OLE.

I've got it working by having to close it (deactivate) , then change the verb to open so the the document opens externally in word, reactivate it and print then quit the document.

CODE

Me.Office.Verb = acOLEVerbOpen
    Me.Office.Action = acOLEActivate
    Me.Office.Object.Application.PrintOut Background:=False
    Me.Office.Object.Application.Quit 

banghead

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Print an OLE object

(OP)
I gave up with OLE as it's too nasty to get an elegant solution working, so I replaced the code with a shell command

CODE

Public 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

    Dim lngHWnd As Long
    Dim lngReturn As Long
    lngReturn = ShellExecute(lngHWnd, "print", Me.FileList, vbNullString, vbNullString, 0) 

This works with my images as well as office documents.

I let the browser object for PDF / Web etc provide their own print option from right mouse click.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close