Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'd like to open an existing file, save it automatically by macro in a different location with a new file name. This portion i can do. I'd like then to delete the original, still active/open workbook. Any suggestions? Thank you, Stefan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Here is an example: Sub Test() On Error GoTo ErrorHandler If ActiveWorkbook.Path < "" Then If Not ActiveWorkbook.ReadOnly Then ActiveWorkbook.Saved = True ActiveWorkbook.ChangeFileAccess xlReadOnly End If Kill ActiveWorkbook.FullName End If Exit Sub ErrorHandler: MsgBox "Fail to delete file: " & ActiveWorkbook.FullName Exit Sub End Sub I am not sure it is perfectly all right. I recommend to close the workbook after deleted. -- HTH okaizawa stefan via OfficeKB.com wrote: Hi, I'd like to open an existing file, save it automatically by macro in a different location with a new file name. This portion i can do. I'd like then to delete the original, still active/open workbook. Any suggestions? Thank you, Stefan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why bother testing if readonly, just set it
Sub Test() On Error GoTo ErrorHandler With ActiveWorkbook If .Path < "" Then .Saved = True .ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName End If End With Exit Sub ErrorHandler: MsgBox "Fail to delete file: " & ActiveWorkbook.FullName Exit Sub End Sub -- HTH Bob Phillips "okaizawa" wrote in message ... Hi, Here is an example: Sub Test() On Error GoTo ErrorHandler If ActiveWorkbook.Path < "" Then If Not ActiveWorkbook.ReadOnly Then ActiveWorkbook.Saved = True ActiveWorkbook.ChangeFileAccess xlReadOnly End If Kill ActiveWorkbook.FullName End If Exit Sub ErrorHandler: MsgBox "Fail to delete file: " & ActiveWorkbook.FullName Exit Sub End Sub I am not sure it is perfectly all right. I recommend to close the workbook after deleted. -- HTH okaizawa stefan via OfficeKB.com wrote: Hi, I'd like to open an existing file, save it automatically by macro in a different location with a new file name. This portion i can do. I'd like then to delete the original, still active/open workbook. Any suggestions? Thank you, Stefan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
Why bother testing if readonly, just set it That is only an example. If a workbook is readonly, "ChangeFileAccess xlReadOnly" fails. (I use Excel 2000) -- Regards, okaizawa |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Bob, Hello okaizawa,
Thank you for your help. This works. I went without the fail-save-option as i am controling the workbooks that are being processed and none would be readonly to begin with. So it should not be an issue... if so, i'd confuse the user one way or another anyway. ;-) Thank you again. Stefan okaizawa wrote: Bob, Why bother testing if readonly, just set it That is only an example. If a workbook is readonly, "ChangeFileAccess xlReadOnly" fails. (I use Excel 2000) -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200507/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I delete a macro when the Delete button is not active? | Excel Worksheet Functions | |||
copy worksheet from closed workbook to active workbook using vba | Excel Worksheet Functions | |||
Preventing opening workbook inside active workbook. | Excel Programming | |||
Delete Characters in an active cell | Excel Programming | |||
Delete row where active cell is located using VBA | Excel Programming |