Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
pk pk is offline
external usenet poster
 
Posts: 27
Default Print to File: In Excel?

Hello, I hope someone can help me with this tough one...

Am using VBA in Excel XP with Windows 2000.

I have several Excel files each consisting of several
pages. I need code to extract each individual page from
each file and save them into separate Excel files.

I was wondering if it is possible to do this, by using VBA
to print each page to a file (as in the [File][Print]
dialog box) to an Excel file rather than a text file. I
need to retain all formats.

Obviously, some pages have partial last pages that extend
beyond the last page break. Some pages include hard page
breaks, some don't. I think for the most part I only have
to worry about horizontal page breaks.

Whether this is or isn't the way to go, could you please
supply me with your example code and best ideas on the way
to proceed? Thanks mountains in advance...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Print to File: In Excel?

Hi,

This code would save each worksheet of the active workbook:

Sub SaveSheets()
Dim sFilename As String
Dim sPath As String
Dim oWorkbook As Workbook
Dim oSheet As Worksheet
Dim oTempbook As Workbook
sFilename = "Copy of sheet "
sPath = "c:\windows\temp\"
Set oWorkbook = ActiveWorkbook
For Each oSheet In oWorkbook.Worksheets
oSheet.Copy
Set oTempbook = ActiveWorkbook
oTempbook.SaveAs sPath & sFilename &
oTempbook.Worksheets(1).Name & ".xls"
oTempbook.Close False
Next
End Sub

Regards,

Jan Karel Pieterse
Excel TA/MVP

-----Original Message-----
Hello, I hope someone can help me with this tough one...

Am using VBA in Excel XP with Windows 2000.

I have several Excel files each consisting of several
pages. I need code to extract each individual page from
each file and save them into separate Excel files.

I was wondering if it is possible to do this, by using

VBA
to print each page to a file (as in the [File][Print]
dialog box) to an Excel file rather than a text file. I
need to retain all formats.

Obviously, some pages have partial last pages that extend
beyond the last page break. Some pages include hard page
breaks, some don't. I think for the most part I only have
to worry about horizontal page breaks.

Whether this is or isn't the way to go, could you please
supply me with your example code and best ideas on the

way
to proceed? Thanks mountains in advance...
.

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
print all worksheets of Excel file to one pdf file Centerfield Excel Discussion (Misc queries) 3 April 30th 09 04:51 AM
my excel is converting all my print jobs to print to file why? Ginger Excel Discussion (Misc queries) 2 April 10th 07 12:28 PM
How do I print from a file created from sending a print to a file Ted Johnston Excel Discussion (Misc queries) 1 February 23rd 06 03:10 AM
Print Excel file to PDF Rob Excel Discussion (Misc queries) 4 February 22nd 05 09:29 AM
FILE Save As / FILE Print greyed out in Excel Jeff Wright Excel Programming 2 September 3rd 03 09:29 AM


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