#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 96
Default After Workbook.Add

I use the following macro I created with the macro recorder to add a new
workbook
without vb code for emailing. What I need to know is how to give a name to
this workbook after it is created. Help would be appreciated.

Workbooks.Add

Windows("Form 200").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Select
Sheets("Cus Futures").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Copy Befo=Workbooks("Book2").Sheets(1)

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 32
Default After Workbook.Add

you need to use save as method i.e.
ActiveWorkbook.SaveAs ("Filename")

"chrisnsmith" wrote:

I use the following macro I created with the macro recorder to add a new
workbook
without vb code for emailing. What I need to know is how to give a name to
this workbook after it is created. Help would be appreciated.

Workbooks.Add

Windows("Form 200").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Select
Sheets("Cus Futures").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Copy Befo=Workbooks("Book2").Sheets(1)

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default After Workbook.Add

chrisnsmith -
to add to what eksh said ... put the line of code he provided right after
your
Workbooks.Add statement before coming back to the primary workbook. You
will also need to change the name of the workbook from "Book2" down in the
final statement you posted here. Might consider using a variable to build up
a new name, this code would take the current workbook's name and add a date
stamp to it to use as the filename. Code could look something like this:

Dim newFileName As String

newFileName = Left(ThisWorkbook.Name, _
InStrRev(ThisWorkbook.Name, ".") - 1)
newFileName = newFileName & "_" & _
Format(Year(Now()), "0000") & "_" & _
Format(Month(Now()), "00") & "_" & _
Format(Day(Now()), "00") & ".xls"

Workbooks.Add
ActiveWorkbook.SaveAs newFileName

Windows("Form 200").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Select
Sheets("Cus Futures").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Copy _
Befo=Workbooks(newFileName).Sheets(1)

"eksh" wrote:

you need to use save as method i.e.
ActiveWorkbook.SaveAs ("Filename")

"chrisnsmith" wrote:

I use the following macro I created with the macro recorder to add a new
workbook
without vb code for emailing. What I need to know is how to give a name to
this workbook after it is created. Help would be appreciated.

Workbooks.Add

Windows("Form 200").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Select
Sheets("Cus Futures").Activate
Sheets(Array("Cus Futures", "House Futures", "Cus Calls", "Cus Puts", _
"House Options", "Cus Indexes")).Copy Befo=Workbooks("Book2").Sheets(1)

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
Adding a chart to large workbook brings workbook activity to a hal Dale Excel Discussion (Misc queries) 6 December 29th 08 05:50 PM
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel workbook is corrupted, workbook automatically saves on start Paul Gooda Excel Discussion (Misc queries) 3 September 28th 06 04:51 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Multiple workbook user's with Master workbook - all password protected Yvon Excel Discussion (Misc queries) 2 March 30th 05 01:34 PM


All times are GMT +1. The time now is 02:28 AM.

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"