Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Print worksheets in external workbooks

I have written the following PrintFiles() procedure to print 3 worksheets
from an external workbook. The code will look in column A for a list of
workbook files. There will be many workbook files (50+) with the same
worksheets to print. If it finds the file, then it opens the workbook and
prints the worksheets.

The code seems to work when I'm in debug mode, but not when I run it without
the debugger. It opens the workbook file and then stops. Any suggestions?

Public Sub PrintFiles()
'
' PrintFiles Macro
' Print files listed in Files tab
'
' Keyboard Shortcut: Ctrl+Shift+P
'
'--Updated: 2008-Aug-29

Dim intRow As Integer
Dim strFile As String

Range("A1").Select
intRow = 1
strFile = ActiveCell.Value
Do Until strFile = ""
'--Check for existence of file
If Dir(strFile) < "" Then
'--open workbook file
Workbooks.Open Filename:=strFile
'--print worksheet 1
ActiveWorkbook.Sheets("13 months").Select
ActiveWorkbook.ActiveSheet.PrintOut Copies:=1
'--print worksheet 2
ActiveWorkbook.Sheets("comp op stmt").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'--print worksheet 3
ActiveWorkbook.Sheets("act v bud").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'--close workbook
ActiveWorkbook.Close False
End If
ActiveCell.Offset(intRow, 0).Activate
strFile = ActiveCell.Value
Loop
Exit Sub
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Print worksheets in external workbooks

Drop the Shift from the shortcut key combination and try it again.

TJ Dowling wrote:

I have written the following PrintFiles() procedure to print 3 worksheets
from an external workbook. The code will look in column A for a list of
workbook files. There will be many workbook files (50+) with the same
worksheets to print. If it finds the file, then it opens the workbook and
prints the worksheets.

The code seems to work when I'm in debug mode, but not when I run it without
the debugger. It opens the workbook file and then stops. Any suggestions?

Public Sub PrintFiles()
'
' PrintFiles Macro
' Print files listed in Files tab
'
' Keyboard Shortcut: Ctrl+Shift+P
'
'--Updated: 2008-Aug-29

Dim intRow As Integer
Dim strFile As String

Range("A1").Select
intRow = 1
strFile = ActiveCell.Value
Do Until strFile = ""
'--Check for existence of file
If Dir(strFile) < "" Then
'--open workbook file
Workbooks.Open Filename:=strFile
'--print worksheet 1
ActiveWorkbook.Sheets("13 months").Select
ActiveWorkbook.ActiveSheet.PrintOut Copies:=1
'--print worksheet 2
ActiveWorkbook.Sheets("comp op stmt").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'--print worksheet 3
ActiveWorkbook.Sheets("act v bud").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'--close workbook
ActiveWorkbook.Close False
End If
ActiveCell.Offset(intRow, 0).Activate
strFile = ActiveCell.Value
Loop
Exit Sub
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Print worksheets in external workbooks

That worked! Thanks a bunch.

TJ


"Dave Peterson" wrote:

Drop the Shift from the shortcut key combination and try it again.

TJ Dowling wrote:

I have written the following PrintFiles() procedure to print 3 worksheets
from an external workbook. The code will look in column A for a list of
workbook files. There will be many workbook files (50+) with the same
worksheets to print. If it finds the file, then it opens the workbook and
prints the worksheets.

The code seems to work when I'm in debug mode, but not when I run it without
the debugger. It opens the workbook file and then stops. Any suggestions?

Public Sub PrintFiles()
'
' PrintFiles Macro
' Print files listed in Files tab
'
' Keyboard Shortcut: Ctrl+Shift+P
'
'--Updated: 2008-Aug-29

Dim intRow As Integer
Dim strFile As String

Range("A1").Select
intRow = 1
strFile = ActiveCell.Value
Do Until strFile = ""
'--Check for existence of file
If Dir(strFile) < "" Then
'--open workbook file
Workbooks.Open Filename:=strFile
'--print worksheet 1
ActiveWorkbook.Sheets("13 months").Select
ActiveWorkbook.ActiveSheet.PrintOut Copies:=1
'--print worksheet 2
ActiveWorkbook.Sheets("comp op stmt").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'--print worksheet 3
ActiveWorkbook.Sheets("act v bud").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'--close workbook
ActiveWorkbook.Close False
End If
ActiveCell.Offset(intRow, 0).Activate
strFile = ActiveCell.Value
Loop
Exit Sub
End Sub


--

Dave Peterson

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
Shortening references to external workbooks Gidders Excel Discussion (Misc queries) 3 June 9th 08 09:43 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
References to external workbooks in excel Fightin Engineer Excel Discussion (Misc queries) 2 February 6th 07 06:50 PM
Need2 batch print all the workbooks in 25 worksheets in one step richie s. Excel Discussion (Misc queries) 2 June 26th 06 03:46 PM
How to print worksheets of the same name in different workbooks without opening leon m via OfficeKB.com Excel Discussion (Misc queries) 1 April 6th 05 01:50 PM


All times are GMT +1. The time now is 03:56 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"