PRINT EMBEDDED WORD OBJECT - trying to open and print an emb

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,786
Office Version
  1. 2016
Platform
  1. Windows
PRINT EMBEDDED WORD OBJECT - trying to open and print an embedded Word object?

I have a letter embebbed on a worksheet. I want to make a button that when clicked will open, print, and then close the document.

I have been trying the recorder and cam get the object open with this code but then the recorder appears to stop recording, probably because I am doing the print action from Word?

ActiveSheet.Shapes("Object 2").Select
'Selection.Verb Verb:=xlOpen
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Re: PRINT EMBEDDED WORD OBJECT - trying to open and print an

Try something like this:

Code:
Sub PrintIt()
    Dim WordApp As Object
    Dim Obj As OLEObject
    Application.ScreenUpdating = False
    Set Obj = ActiveSheet.OLEObjects("Object 2")
    Obj.Activate
    Set WordApp = GetObject(, "Word.Application")
    WordApp.Activedocument.PrintOut
    Set WordApp = Nothing
    Range("A1").Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Re: PRINT EMBEDDED WORD OBJECT - trying to open and print an

Andrew - just tried it. Looks like it selected the Object 2, but then the code breaks at "WordApp.Activedocument.PrintOut"
 
Upvote 0
Re: PRINT EMBEDDED WORD OBJECT - trying to open and print an

Sorry EM, I had an instance of Word open when I tested it. Try this:

Code:
Sub PrintIt()
    Dim WordApp As Object
    Dim Obj As OLEObject
    Application.ScreenUpdating = False
    Set WordApp = CreateObject("Word.Application")
    Set Obj = ActiveSheet.OLEObjects("Object 1")
    Obj.Activate
    WordApp.ActiveDocument.PrintOut
    Set WordApp = Nothing
    Range("A1").Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Re: PRINT EMBEDDED WORD OBJECT - trying to open and print an

Andrew - still breaking at WordApp.ActiveDocument.PrintOut.

I had Word closed and have the macro connected to a button. When pressed the embedded object is selected but the code breaks.

We are using Windows 2000 and Office XP--wonder is that is causing a the problem?
 
Upvote 0

Forum statistics

Threads
1,215,832
Messages
6,127,149
Members
449,365
Latest member
AlienSx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top