Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi jim9912,
Can you give some examples of the list? -- Regards, Zack Barresse, aka firefytr To email, remove NOSPAM "jim9912" wrote in message ps.com... 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? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Regards, Zack Barresse, aka firefytr To email, remove NOSPAM "jim9912" wrote in message oups.com... 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
THanks so much for helping -- I'm using Office 97 (not my decision - corporate stinginess) so I used the object library 8.0, the only option listed in references. When I run the macro I get the following error: run time error '4198' command failed The debugger points to this line: Set WDDoc = WDApp.Documents.Open(c.Value) My data starts in cell d5, so I changed Set rngFiles = Range("A2", Cells(Rows.Count, "A").End(xlUp)) to: Set rngFiles = Range("D5", Cells(Rows.Count, "D").End(xlUp)) Same error as above. I'm a vba novice, so forgive me if I'm missing something obvious. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you sure that cell C contains the name of an existing file?
If it contains a filename without the directory folder path, you'll need to use ChDrive and ChDir to set the default folder. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "jim9912" wrote in message ups.com... Hi, THanks so much for helping -- I'm using Office 97 (not my decision - corporate stinginess) so I used the object library 8.0, the only option listed in references. When I run the macro I get the following error: run time error '4198' command failed The debugger points to this line: Set WDDoc = WDApp.Documents.Open(c.Value) My data starts in cell d5, so I changed Set rngFiles = Range("A2", Cells(Rows.Count, "A").End(xlUp)) to: Set rngFiles = Range("D5", Cells(Rows.Count, "D").End(xlUp)) Same error as above. I'm a vba novice, so forgive me if I'm missing something obvious. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Printing Macro for Excel 97 | Excel Discussion (Misc queries) | |||
Printing Problem In Excel Due to Macro? | Excel Discussion (Misc queries) | |||
Excel printing macro problem | Excel Programming | |||
Excel MAcro/Printing | Excel Programming | |||
Help. Excel Printing Macro | Excel Programming |