Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Printing Embedded Word Document | Excel Programming | |||
Embedded Word document | Excel Discussion (Misc queries) | |||
Automate Embedded Word Document | Excel Programming | |||
Read embedded word document by VBA | Excel Programming | |||
Read embedded word document | Excel Programming |