View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
lieven lieven is offline
external usenet poster
 
Posts: 10
Default printout method on embedded word document fails

Hi NICKHK,

looks like i was to fast with my response,

now I get a "runtime error 4605 - method not available" on the printout
statement

i' m running slightly insane here. have invested already 2 days in this
undocumented problem

hope you have the answer

thanks

"NickHK" wrote:

I am never sure with an OLEObject when to use .Parent, .Object or
..Application. After some trial and error I get something to work, but the
help seems lacking in this area.
Maybe someone has a link that document this ?

NickHK

"lieven" wrote in message
...
Thanks NickHK,


works fine.
So adressing the OLEobject via its "object" property doesn't work ?

"NickHK" wrote:

This works for me, using late binding. I have not tested much and no

error
handling used:

Private Sub CommandButton1_Click()
Dim WordDoc As OLEObject
Dim WordApp As Object

Set WordDoc = ActiveSheet.OLEObjects(1)

With WordDoc
.Activate
Set WordApp = .Object.Application
End With

With WordApp
With .activedocument
.PrintOut
.Close False
End With
.Quit
End With

End Sub

NickHK

"lieven" wrote in message
...
I have a word document embedded in an excel worksheet

when i try to print the document from vba i get an automation error.

my code is something like this

sub test()
dim owordapp as word.application
dim oworddoc as word.document
dim oembobj as oleobject

set oembobj=thisworkbook.somesheet.oleobjects("mydoc")
oembobj.activate

set owordapp=oembobj.object.application
set oworddoc=owordapp.activedocument

oworddoc.printout

.....
end sub

using office 2003 on xp sp2 system