Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Macro to Print All Files in a Folder

Off google I found the following code, which I have since modified to
accomplish my subject objective; <<to no avail can someone assist?

Sub Tester9()
PathOnlysource = "C:\Formulas\Backuptest"
ChDir PathOnlysource
TheFile = Dir(PathOnlysource & "\*.xls")
Do While TheFile < ""
ActiveSheet.PrintOut
TheFile = Dir
Loop
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Print All Files in a Folder

You need to open each of the workbooks in the loop before trying t
print them out.


PATHONLYSOURCE = \"C:\TEST\"
CHDIR PATHONLYSOURCE
THEFILE = DIR(PATHONLYSOURCE & \"\*.XLS\")
DO WHILE THEFILE < \"\"
WORKBOOKS.OPEN FILENAME:=PATHONLYSOURCE & \"\\" & THEFILE
ACTIVESHEET.PRINTOUT
WORKBOOKS(THEFILE).CLOSE
THEFILE = DIR
LOOP



Rolli

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to Print All Files in a Folder

Jim,

What is that you want that you don't get? It may seem obvious, but I tried
this with my directory and it worked fine for me.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim May" wrote in message
news:SeuKc.374$ci.127@lakeread04...
Off google I found the following code, which I have since modified to
accomplish my subject objective; <<to no avail can someone assist?

Sub Tester9()
PathOnlysource = "C:\Formulas\Backuptest"
ChDir PathOnlysource
TheFile = Dir(PathOnlysource & "\*.xls")
Do While TheFile < ""
ActiveSheet.PrintOut
TheFile = Dir
Loop
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to Print All Files in a Folder

did you add code to open the workbook, or just get "n" copies of the sheet
that was active when you ran the code?

--
Regards,
Tom Ogilvy

"Bob Phillips" wrote in message
...
Jim,

What is that you want that you don't get? It may seem obvious, but I tried
this with my directory and it worked fine for me.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim May" wrote in message
news:SeuKc.374$ci.127@lakeread04...
Off google I found the following code, which I have since modified to
accomplish my subject objective; <<to no avail can someone assist?

Sub Tester9()
PathOnlysource = "C:\Formulas\Backuptest"
ChDir PathOnlysource
TheFile = Dir(PathOnlysource & "\*.xls")
Do While TheFile < ""
ActiveSheet.PrintOut
TheFile = Dir
Loop
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to Print All Files in a Folder

Tom:
Thanks; No, I failed to "open" the workbooks. I've since
gotten my answer from code written by Ron de Bruin;
Have a good one..

"Tom Ogilvy" wrote:

did you add code to open the workbook, or just get "n" copies of the sheet
that was active when you ran the code?

--
Regards,
Tom Ogilvy

"Bob Phillips" wrote in message
...
Jim,

What is that you want that you don't get? It may seem obvious, but I tried
this with my directory and it worked fine for me.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim May" wrote in message
news:SeuKc.374$ci.127@lakeread04...
Off google I found the following code, which I have since modified to
accomplish my subject objective; <<to no avail can someone assist?

Sub Tester9()
PathOnlysource = "C:\Formulas\Backuptest"
ChDir PathOnlysource
TheFile = Dir(PathOnlysource & "\*.xls")
Do While TheFile < ""
ActiveSheet.PrintOut
TheFile = Dir
Loop
End Sub









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default Macro to Print All Files in a Folder

Bob: Thanks for looking in on this..
What I was trying to do << and have since accomplished-below was:
using what i call a surrogate workbook to run a macro which opens
each .xls file in a folder and prints each and then closes each. The code
I posted was printing my surrogate activesheet twice since my test folder had two files in it..
I later found this code by Ron de Bruin off google.. [works perfectly]

Sub PrintAllinFolder()
Dim i As Long
Dim WB As Workbook
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\WINDOWS\Desktop\Temp Excel Formulas\Backuptest"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
Set WB = Workbooks.Open(.FoundFiles(i))
WB.PrintOut
WB.Close False
Next i
End If
End With
Application.ScreenUpdating = True
End Sub



"Bob Phillips" wrote:

Jim,

What is that you want that you don't get? It may seem obvious, but I tried
this with my directory and it worked fine for me.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim May" wrote in message
news:SeuKc.374$ci.127@lakeread04...
Off google I found the following code, which I have since modified to
accomplish my subject objective; <<to no avail can someone assist?

Sub Tester9()
PathOnlysource = "C:\Formulas\Backuptest"
ChDir PathOnlysource
TheFile = Dir(PathOnlysource & "\*.xls")
Do While TheFile < ""
ActiveSheet.PrintOut
TheFile = Dir
Loop
End Sub





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
Macro creating folder and files automatically, without permission. pokdbz Excel Discussion (Misc queries) 1 November 8th 07 04:24 PM
Macro to create a folder and copy files GainesvilleWes New Users to Excel 2 February 26th 07 06:33 PM
I would like to print the titles of files inside a folder. onenevadadollar Excel Worksheet Functions 1 November 17th 05 12:26 AM
Macro to copy range from Excel files in folder nc Excel Discussion (Misc queries) 1 June 15th 05 11:11 AM
how do i print a list of files in a folder in excel? mikie New Users to Excel 4 June 6th 05 04:27 AM


All times are GMT +1. The time now is 04:39 PM.

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

About Us

"It's about Microsoft Excel"