Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Saving Worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 19 Sep 2007 07:34 GMT
I have a vba application I'm working on that creates numerous worksheets
within a workbook.  I need to save off a copy of specific worksheets from the
workbook to their own file name.  The object model appears to support that by
using the saveas method with a worksheet object rather than the workbook
object.  When I try to actually do that in code, though, it saves the entire
workbook.  My work around is to save it then delete all of the worksheets I
don't want, but that seems to be an around the elbow way to get the job done.
Is there a way to save a worksheet out of a workbook?

Thanks,
 Mike
Stefi - 19 Sep 2007 08:22 GMT
Try this:
Sub test()
   Sheets("YourSheetName").Select
   Sheets("YourSheetName").Copy
   ActiveWorkbook.SaveAs Filename:= _
       "Yourpath" & "YourSheetName", _
       FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
       ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

Regards,
Stefi

„Mike” ezt írta:

> I have a vba application I'm working on that creates numerous worksheets
> within a workbook.  I need to save off a copy of specific worksheets from the
[quoted text clipped - 7 lines]
> Thanks,
>   Mike
Mike - 19 Sep 2007 20:26 GMT
Thanks Stefi...that worked very well!

> Try this:
> Sub test()
[quoted text clipped - 22 lines]
> > Thanks,
> >   Mike
Stefi - 20 Sep 2007 07:12 GMT
You are welcome! Thanks for the feedback!
Stefi

„Mike” ezt írta:

> Thanks Stefi...that worked very well!
>
[quoted text clipped - 24 lines]
> > > Thanks,
> > >   Mike
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.