#1   Report Post  
Posted to microsoft.public.excel.misc
KJ KJ is offline
external usenet poster
 
Posts: 43
Default save as macro

Here is a macro I created. Run I run the macro it creates the new file with
the correct filename in the correct location. However I still have the
previous (Book1) file open.
What I want is to close Book1 without saving.

Any help would be greatly appreciated.
Thanks, Ken.

Sub copyws()
Dim strName As String
Dim ws As Worksheet
strName = "C:\Documents and Settings\Ken1\My Documents\Quotes\" &
Range("A1").Value
Set ws = ThisWorkbook.Sheets(1)
Application.Workbooks.Add
ws.Copy befo=ActiveWorkbook.Sheets(1)
ActiveWorkbook.SaveAs strName

Set ws = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default save as macro

hi
can't do that. small technicallity. a macro must finish before the file can
be closed and a macro cannot close the file it resides in.
sorry
regards
FSt1

"KJ" wrote:

Here is a macro I created. Run I run the macro it creates the new file with
the correct filename in the correct location. However I still have the
previous (Book1) file open.
What I want is to close Book1 without saving.

Any help would be greatly appreciated.
Thanks, Ken.

Sub copyws()
Dim strName As String
Dim ws As Worksheet
strName = "C:\Documents and Settings\Ken1\My Documents\Quotes\" &
Range("A1").Value
Set ws = ThisWorkbook.Sheets(1)
Application.Workbooks.Add
ws.Copy befo=ActiveWorkbook.Sheets(1)
ActiveWorkbook.SaveAs strName

Set ws = Nothing

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default save as macro

Book1 is the workbook that contains the macro?

If yes, then just add:

thisworkbook.close savechanges:=false 'or True

right before the "End Sub" line.


KJ wrote:

Here is a macro I created. Run I run the macro it creates the new file with
the correct filename in the correct location. However I still have the
previous (Book1) file open.
What I want is to close Book1 without saving.

Any help would be greatly appreciated.
Thanks, Ken.

Sub copyws()
Dim strName As String
Dim ws As Worksheet
strName = "C:\Documents and Settings\Ken1\My Documents\Quotes\" &
Range("A1").Value
Set ws = ThisWorkbook.Sheets(1)
Application.Workbooks.Add
ws.Copy befo=ActiveWorkbook.Sheets(1)
ActiveWorkbook.SaveAs strName

Set ws = Nothing

End Sub


--

Dave Peterson
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
macro to save as frageo64 Excel Discussion (Misc queries) 2 November 13th 07 06:57 AM
MACRO SAVE HELP DP7 Excel Worksheet Functions 2 October 17th 07 08:01 PM
Please help macro for save DP7 Excel Worksheet Functions 1 October 11th 07 10:31 PM
Macro to Save without the Save Message Ellen G Excel Discussion (Misc queries) 4 February 23rd 07 08:52 PM
Macro-Save as Lois Excel Discussion (Misc queries) 4 May 20th 05 10:53 PM


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