Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to save as | Excel Discussion (Misc queries) | |||
MACRO SAVE HELP | Excel Worksheet Functions | |||
Please help macro for save | Excel Worksheet Functions | |||
Macro to Save without the Save Message | Excel Discussion (Misc queries) | |||
Macro-Save as | Excel Discussion (Misc queries) |