Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default printout method on embedded word document fails

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default printout method on embedded word document fails

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default printout method on embedded word document fails

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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default printout method on embedded word document fails

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






  #5   Report Post  
Posted to microsoft.public.excel.programming
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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default printout method on embedded word document fails

Works for me.
Are you sure you are using the correct syntax, with all the correct "." in
place. Try:
WordApp.Activedocument.PrintOut

NickHK

"lieven" wrote in message
...
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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Embedded Word Document Mark Excel Programming 0 May 16th 06 08:54 PM
Embedded Word document bforster1 Excel Discussion (Misc queries) 0 November 2nd 05 08:50 PM
Automate Embedded Word Document Peter Graney Excel Programming 0 August 12th 04 06:01 PM
Read embedded word document by VBA rs Excel Programming 0 August 26th 03 04:33 PM
Read embedded word document rs Excel Programming 0 August 22nd 03 07:24 PM


All times are GMT +1. The time now is 04:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"