Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Printing from EXCEL using a macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Printing from EXCEL using a macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Printing from EXCEL using a macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Printing from EXCEL using a macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Printing from EXCEL using a macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Printing from EXCEL using a macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Macro for Excel 97 dhstein Excel Discussion (Misc queries) 0 April 27th 09 05:26 PM
Printing Problem In Excel Due to Macro? [email protected] Excel Discussion (Misc queries) 4 March 20th 07 04:05 PM
Excel printing macro problem Cam[_6_] Excel Programming 2 February 18th 06 03:48 PM
Excel MAcro/Printing kwedde01 Excel Programming 0 June 9th 05 08:12 PM
Help. Excel Printing Macro wmcray[_5_] Excel Programming 6 September 23rd 04 04:47 AM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"