Printing from Excel using a macro - Phase II

J

jim9912

The following is a solution I recently implemented. Now the list of
links described below has evolved into something that may also contain
links to excel files and pdf files. My macro uses MS Word as the App.
Is there a way that I can have the macro choose the appropriate app as
it reads the list of links? As of right now, predictably, only the
Word foles are printing correctly.



Printing from EXCEL using a macro
All 6 messages in topic - view as tree
From: jim9912 - view profile
Date: Wed, Apr 12 2006 4:38 pm
Email: "jim9912" <[email protected]>
Groups: microsoft.public.excel.programming
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author


I am trying to develop a macro to read a list of links from an excel
spreadsheet and print each of the files associated with the links. The

number of files in the
list may change.

ANy ideas?


Reply





From: Zack Barresse - view profile
Date: Wed, Apr 12 2006 4:53 pm
Email: "Zack Barresse" <[email protected]>
Groups: microsoft.public.excel.programming
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author


Hi jim9912,

Can you give some examples of the list?


--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAM







- Hide quoted text -
- Show quoted text -
I am trying to develop a macro to read a list of links from an excel
spreadsheet and print each of the files associated with the links. The
number of files in the
list may change.
ANy ideas?



Reply Rate this post: Text for clearing space





From: jim9912 - view profile
Date: Wed, Apr 12 2006 8:13 pm
Email: "jim9912" <[email protected]>
Groups: microsoft.public.excel.programming
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author


Sure, here's a sample, but te path, filename, and number of links will
vary.

C:\Project Books\Templates\Clearance Sheets\BrgThrust&JournalClr.doc
C:\Project Books\Templates\Clearance Sheets\BrgThrust&JournalClr2.doc
C:\Project Books\Templates\Clearance Sheets\BrgThrustPadInsp.doc
C:\Project Books\Templates\Clearance Sheets\RotorAxialPosition.doc
C:\Project Books\Templates\Clearance Sheets\RotorAxPosThrustClr.doc


Reply





From: Zack Barresse - view profile
Date: Thurs, Apr 13 2006 2:48 pm
Email: "Zack Barresse" <[email protected]>
Groups: microsoft.public.excel.programming
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author


Okay, making some assumptions here, this should do you right ...

Sub PrintDocuments()
'Must set a reference (Tools | References) to:
' Microsoft Word 11.0 Object Library
'11.0 = 2003, 10.0 = 2002 (XP), 9.0 = 2000, etc.
Dim WDApp As Word.Application, WDDoc As Word.Document
Dim c As Range, rngFiles As Range
Set rngFiles = Range("A2", Cells(Rows.Count, "A").End(xlUp))
Set WDApp = New Word.Application
WDApp.Visible = True
For Each c In rngFiles
Set WDDoc = WDApp.Documents.Open(c.Value)
WDDoc.PrintOut copies:=1
WDDoc.Close False
Set WDDoc = Nothing
Next c
WDApp.Quit False
Set WDApp = Nothing
End Sub


This assumes that the activesheet will house the data you posted,
otherwise
you'll need to explicitly set it. It also assumes the data starts in
A2 and
goes downward and is the only data in that column. You'll need to set
a
reference to the Word Object Library as shown in the comments in the
code.


If you have any questions let me know.


HTH
 

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