Jimmyg1964
05-24-2006, 06:04 AM
:banghead:
Hi all, I have posted on several boards and have not recieved a response -- please help if you can?
I am wanting to develop a macro for excel which will read (from a worksheet) a list of hyperlinks to .pdf, .doc, and .xls files and print them using the appropriate application. Theoretically, I know I would have to use some kind of for-next and/or case structure but I don't know how to implement it. Someone has helped me get started, but the macro I have only works for the word documents. Here is the code I have:
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
And here is a sample of the file list, which will change in contents and number of elements:
C:\Project Books\Templates\Clearance Sheets\BrgThrust&JournalClr.doc
C:\Project Books\Templates\Clearance Sheets\BrgThrust.doc
C:\Project Books\Templates\Clearance Sheets\BrgThrustPadInsp.pdf
C:\Project Books\Templates\Clearance Sheets\RotorAxialPosition.xls
C:\Project Books\Templates\Clearance Sheets\RotorAxPosThrustClr.doc
If you can help, I'd be forever indebted.
Hi all, I have posted on several boards and have not recieved a response -- please help if you can?
I am wanting to develop a macro for excel which will read (from a worksheet) a list of hyperlinks to .pdf, .doc, and .xls files and print them using the appropriate application. Theoretically, I know I would have to use some kind of for-next and/or case structure but I don't know how to implement it. Someone has helped me get started, but the macro I have only works for the word documents. Here is the code I have:
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
And here is a sample of the file list, which will change in contents and number of elements:
C:\Project Books\Templates\Clearance Sheets\BrgThrust&JournalClr.doc
C:\Project Books\Templates\Clearance Sheets\BrgThrust.doc
C:\Project Books\Templates\Clearance Sheets\BrgThrustPadInsp.pdf
C:\Project Books\Templates\Clearance Sheets\RotorAxialPosition.xls
C:\Project Books\Templates\Clearance Sheets\RotorAxPosThrustClr.doc
If you can help, I'd be forever indebted.