PDA

View Full Version : Help with printing macro - -please!!!



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.

austenr
05-24-2006, 09:21 AM
Cross Post on Ozgrid and probably others:

http://www.ozgrid.com/forum/showthread.php?t=50952&highlight=printing+macro

The likely reason you are not getting replies is that you have this question posted in numerous forums. Its not that people are avoiding you but are reluctant to help you because like I most people that visit this board, they visit other boards as well. If they see this exact question posted in other forums it makes them reluctant to try to help because they feel they may be wasting their time as there may be someone helping you on another board that they do not know of.

Everyone at VBAX likes to help others and there are some AWSOME resources here. If you have posted your question on other boards, please as a courtesy, provide a link to those other boards so others can see if there has been any answers to your question. This helps everyone and will help you get the problem you have solved. :thumb