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:
Any help is appreciated. Not sure if this code is what I need, or if I need something different.
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.