Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing twice instead of Once.


Sub Printbooks()
DirName = InputBox("Enter the directory to search including final
:", "Print Books")
Nextbook = Dir(DirName & "*.xls")
Do While (Nextbook < "" Or Nextbook < "G:\M
Documents\Report_printing_at_a_go\Printbooks.XLS")
MsgBox Nextbook & " is being opened"

Workbooks.Open DirName & Nextbook
For Each sheet In Workbooks()
On Error Resume Next
If Worksheets("Report").Activate < "" Then
' Application.Dialogs(xlDialogPrinterSetup).Show
If ActiveSheet.Name = "Report" Then ActiveSheet.PrintOu
preview:=False, Copies:=1
'ActiveWorkbook.PrintOut
ActiveSheet.Close
End If
Next sheet

MsgBox Nextbook & " is being closed"
ActiveWorkbook.Close
Nextbook = Dir()
Loop

End Sub

The above code intend print sheet named report once. Please help me

--
jr200
-----------------------------------------------------------------------
jr2002's Profile: http://www.excelforum.com/member.php...fo&userid=1544
View this thread: http://www.excelforum.com/showthread.php?threadid=27042

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing twice instead of Once.


Posting twice the same day tends to *delay* answers rather tha
increasing the chance of a reply. I have wasted too much time in th
past answering one only to find someone else has put an answer i
another posting. So I leave it alone.

I have amended your code but not tested it.

Code
-------------------

Sub Printbooks()
'- get dir
DirName = InputBox("Enter the directory to search including final \ :", "Print Books")
Nextbook = Dir(DirName & "*.xls")
'- open workbooks
Do While (Nextbook < "" Or Nextbook < _
"G:\My Documents\Report_printing_at_a_go\Printbooks.XLS")
MsgBox Nextbook & " is being opened"
Workbooks.Open DirName & Nextbook
'==============================================
' AMENDED CODE
'- print report
ActiveWorkbook.Worksheets("Report").PrintOut preview:=False, Copies:=1
'==============================================
'-close/next
MsgBox Nextbook & " is being closed"
ActiveWorkbook.Close
Nextbook = Dir()
Loop
End Sub

-------------------

--
Brian

-----------------------------------------------------------------------
BrianB's Profile: http://www.excelforum.com/member.php...tinfo&userid=5
View this thread: http://www.excelforum.com/showthread.php?threadid=27042

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
Excel 2003 printing problem--printing 1 document on 2 pages Bons Excel Discussion (Misc queries) 0 December 24th 09 04:15 PM
Excel Printing --Borders are not printing on the same page as data Stup88 Excel Discussion (Misc queries) 1 August 7th 07 09:34 AM
Printing a heading on each new page when printing Brian Excel Discussion (Misc queries) 3 November 15th 06 05:22 PM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 01:58 AM
Printing? Worksheets not printing the same on multiple pc's! 43fan Excel Programming 2 April 29th 04 02:34 PM


All times are GMT +1. The time now is 09:58 AM.

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"