LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Split file, saving each tab/worksheet to a new workbook, w/tab asworkbook name?


springfield_rifles;487838 Wrote:
I tried this program and it giving a runtime error '1004'; the sheet you
are
copying contains cells that have more then 255 characters. When you
copy the
sheet only the first 255 characters in each cell will be copied. To
copy all
the characters, copy the cells to a new sheet instead of copying the
entire
sheet.

When I try to debug it highlights this line: w.Copy

Is there a value I can put in that will fix this problem?


"StargateFanNotAtHome" wrote:

Okay, this usually doesn't happen since I don't know the terminology
well in vb, but today I got lucky. I googled for

ActiveWorkbook.Path,
same as I might always do, but this time I did stumble upon an
alternative, ThisWorkbook.Path and this _did_ save the new workbooks
to the same folder as the original. How come the

ActiveWorkbook.Path
saves to our personal folder here at work I'll never know.
ActiveWorkbook.Path logically sounds like it would deal with the

same
folder but there must be some quirk here in the office that it sends
it off to my "personal" root network work folder. I also added a

sort
of prefix to the new workbook name so that in case the person they
staffed this position with happens to do this in a folder populated
with other files, the workbooks will all stay grouped together

because
of the "zFileSplit- " at the beginning of each file. So the

slightly
modified vb script looks like this now:

---------------------------------------------------
Sub WORKBOOK_Split_and_new_files_named_by_tab()

Dim w As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In ActiveWorkbook.Worksheets
w.Copy
With ActiveWorkbook
.SaveAs Filename:=ThisWorkbook.Path _
& "\zSplitFile- " & w.Name & ".xls" 'or .xlsx; if you're
using XL2007 fully and not in compatibility mode, use .xlsx instead
of .xls
.Close
End With
Next w
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
---------------------------------------------------

Thanks so much! This will make it a heck of a lot easier to manage
their huge Excel file.

Cheers, :oD


I would like to take this a step further by doing 2 more things:

(1.) I would like to save each tab/worksheet as a seperate .PDF with
the tab name as the file name.

(2.) Would it be possible to first (1.) and save each seperate .PDF in
seprate folders in the same directory as the ActiveWorkbook where the
Folder name is the same as the tab name?


--
cjonz
------------------------------------------------------------------------
cjonz's Profile: http://www.thecodecage.com/forumz/member.php?userid=995
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=129183

 
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
FYI Excel 2007: Saving a xlsm file with a hidden worksheet activated makes worksheet visible David G.[_3_] Excel Programming 0 August 3rd 09 07:16 PM
Split a worksheet into multiple worksheets of the same Excel file shree Excel Discussion (Misc queries) 1 November 4th 08 08:24 PM
Split a worksheet into multiple worksheets of the same Excel file shree Excel Programming 1 November 4th 08 08:24 PM
Saving just 1 worksheet out of a workbook to a separate file Rich D Excel Discussion (Misc queries) 1 January 23rd 08 02:31 AM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM


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