Printing Issue

J

John

I'm need to print a Word document that is embedded in
an Excel worksheet. The code I currently have will work
successfully once, but will fail on the second attempt.
I would appreciate any help at all. Here is the code
that I currently have...

Sub Comments()
Set wrd = CreateObject("Word.Application")
wrd.Visible = True
Worksheets("Comments").OLEObjects("Object 6").Select
Worksheets("Comments").OLEObjects("Object 6").Activate
With ActiveDocument
.PrintOut
.Close SaveChanges:=wdDoNotSaveChanges
End With
wrd.Quit
End Sub

Thanks
 
S

Stephen Bullen

Hi John,
I'm need to print a Word document that is embedded in
an Excel worksheet. The code I currently have will work
successfully once, but will fail on the second attempt.
I would appreciate any help at all. Here is the code
that I currently have...

Sub Comments()
Set wrd = CreateObject("Word.Application")
wrd.Visible = True
Worksheets("Comments").OLEObjects("Object 6").Select
Worksheets("Comments").OLEObjects("Object 6").Activate
With ActiveDocument
.PrintOut
.Close SaveChanges:=wdDoNotSaveChanges
End With
wrd.Quit
End Sub

How about (untested):

Sub Comments()
Worksheets("Comments").OLEObjects("Object 6").Object.PrintOut
End Sub

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie
 
G

Guest

Stephen

I sincerely appreciate your suggestion. I got the following message when I ran your code

"Unable to get the Object property of the OLEObject class.

Any other thoughts? They would certainly be welcomed

Thanks
Joh

----- Stephen Bullen wrote: ----

Hi John
I'm need to print a Word document that is embedded in
an Excel worksheet. The code I currently have will work
successfully once, but will fail on the second attempt.
I would appreciate any help at all. Here is the code
that I currently have..
Set wrd = CreateObject("Word.Application"
wrd.Visible = Tru
Worksheets("Comments").OLEObjects("Object 6").Selec
Worksheets("Comments").OLEObjects("Object 6").Activat
With ActiveDocumen
.PrintOu
.Close SaveChanges:=wdDoNotSaveChange
End Wit
wrd.Qui
End Su

How about (untested)

Sub Comments(
Worksheets("Comments").OLEObjects("Object 6").Object.PrintOu
End Su

Regard

Stephen Bulle
Microsoft MVP - Exce
www.BMSLtd.i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top