I have a macro that prints all doc attachments that are
embedded as objects in a Word 2000 document (code provided
at end of doc). I have it set to to skip those with PROG
ID of "package" but print all others (like Excel spread
sheets , other Word docs, etc.).
It works fine for Word docs but I have 2 problems:
1. It doesn't print Excel spreadsheets even though they do
not appear with and ProgID of "package". I suspect I need
to switch control somehow to Excel to open the sheet then
print then close it but I'm not sure if that is true
and/or if there is an easier way. Also, I don't know how
to do this if it is needed.
2. I also want to be able to print items with .txt
extensions but they have an ID of "package". Any one know
how I can programmatcally open/print these docs? I could
check for file extension .txt but then how do I get it to
open/print it? I suspect that would put me in the same
bind as #1 -- opening/printing via another application
(i.e. notepad?)?
Thanks for your help!
JoAnn
Here is mycode:
Sub PRINT_Attachments()
'
' PRINT_Attachments Macro -- to print attachments in a doc
' Comments: TYPE=1 is an embedded object
x = 0
x = ActiveDocument.InlineShapes.Count
Do While x <> 0
If ActiveDocument.InlineShapes(x).Type = 1 Then
If ActiveDocument.InlineShapes(x).OLEFormat.ProgID
<> "Package" Then
ActiveDocument.InlineShapes(x).Activate
ActiveWindow.PrintOut
ActiveWindow.Close
End If
End If
x = x - 1
Loop
End Sub
.
Faced this one square on just recently. My current guess is to use the
classtype of the creator to link to the host to operate the object.
This is nasty business as every app has different methods.
Yes, your activewindow ONLY applies to Word, not the clients launched.
If you do find a solution, by golly I'd love to see it :-)
"JoAnn" <JoAnn....@comverse.com> was spinning this yarn:
Steve Hudson
Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email: word_h...@yahoo.com.au
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 728 pages of dump left and dropping...
The VBA Beginner's Spellbook: For all VBA users.