Printing Embedded Word Document and Active Sheets

ob1kin0bi

New Member
Joined
Jun 5, 2013
Messages
12
I have a spreadsheet that has multiple tabs in it. I need to be able to FIRST print the 'Comments' tab (which contains the embedded word doc that is 4 pages long), then print all active sheets that are visible. I've tried this piece of code, but I throw an error "User-Defined Type not defined" on the 'Dim oDocument as Document line:
Code:
Option Explicit
Sub Print_All()
     '
     ' PRINT_Attachments Macro -- to print attachments in a doc
     ' Comments: TYPE=1 is an embedded object
    Dim oDocument As Document
    Dim x As Integer
    Dim countx As Integer
    Dim counte As Integer
    Application.Documents.Add ActiveDocument.FullName
    Set oDocument = ActiveDocument
    With Documents(oDocument).ActiveWindow.View
        WordBasic.AcceptAllChangesInDoc
    End With
     
    For x = 1 To Documents(oDocument).InlineShapes.Count
        If Documents(oDocument).InlineShapes(x).Type = 1 Then
            If Documents(oDocument).InlineShapes(x).OLEFormat.progID <> "Package" Then
                Documents(oDocument).InlineShapes(x).Activate
                 '             'the activedocument is now the newly opened document
                 '            ActiveDocument.PrintOut
                ActiveDocument.Close
                countx = countx + 1
            End If
        End If
    Next x
    ActiveDocument.Saved = True
    ActiveDocument.Close
    MsgBox "This Document contains: " & countx & " embedded documents"
End Sub

Any help is appreciated. Not sure if this code is what I need, or if I need something different.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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