Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default saving a sheet in a new workbook

chijanzen,

it makes a new workbook, but just calls it workbook 2.

it inserts the sheet, but does not save the workbook.

it still says error 400.

"chijanzen" wrote:

steve:

i want the new workbook saved in the same directory as the
original workbook.


fname = ThisWorkbook.Path & "\" & Date & ".xls"
Set wbk = Workbooks.Add
ThisWorkbook.Worksheets("Sheet1").Copy _
After:=wbk.Worksheets("Sheet1")
wbk.SaveAs fname

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"steve" wrote:

thanks for the reply chijanzen,

i got an error 400.

if this helps, i want the new workbook saved in the same directory as the
original workbook. this way, you don't need to find a folder with the same
name.

please let me knwo if you don't understand what i mean

Thanks,
steve

"chijanzen" wrote:

steve:

try it,

Sub test()
rpath = "P:\Projects\Jobs\"
rname = Split(ThisWorkbook.Name, ".")
fpath = rpath & rname(0)
fname = fpath & "\" & Date & ".xls"
If Dir(fpath, vbDirectory) = "" Then
MkDir fpath
End If
Set wbk = Workbooks.Add
ThisWorkbook.Worksheets("Sheet1").Copy _
After:=wbk.Worksheets("Sheet1")
wbk.SaveAs fname
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"steve" wrote:

Using a button:

1) copy a sheet into a new workbook
2) save the workbook into the following directory:

"P:\Projects\Jobs\....

the next folder will be the same name as the original workbook

is this possible?

i also want to name the new workbook with today's date.

i appreciate any help

thanks,
steve

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
specify each sheet name when saving workbook as html [email protected] Excel Discussion (Misc queries) 3 May 7th 07 07:01 PM
Saving a sheet in a workbook as .csv but not changing workbook name gloryofbach[_4_] Excel Programming 3 October 30th 05 08:50 PM
Saving one sheet within a workbook David Vollmer Excel Discussion (Misc queries) 2 September 14th 05 06:04 PM
saving sheet as new workbook Nigel Excel Programming 1 August 12th 05 02:35 AM
Saving only 1 sheet of a workbook Jay Wilson Excel Programming 4 February 2nd 04 04:38 PM


All times are GMT +1. The time now is 09:07 PM.

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"