Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close Shell
Hi All,
With this script I open a file: Shell "explorer.exe " & ReNameFolder & SelectedFile Through another script I rename the file and save it in a different folder. Name ReNameFolder & SelectedFile As SQFolder & NewFileNm How do I close the "Shell.." before I run the rename script? I tried dimming Filename as variant, filename=shell... and then filename.close or quit, but I got an object error. Basically I want to take a file (could be a pdf, tif, or xfdl), rename it and save it to a different folder. And don't want to have to go back and delete it once done. Any help or suggestions would be greatly appreciated. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close Shell
If you just want to delete the original file, use the Kill command. If you
want to get rid of the Shell Object then: Sub pig() x = Shell("explorer.exe C:\Temp\third.xls") Set x = Nothing End Sub -- Gary''s Student - gsnu200797 "BigPig" wrote: Hi All, With this script I open a file: Shell "explorer.exe " & ReNameFolder & SelectedFile Through another script I rename the file and save it in a different folder. Name ReNameFolder & SelectedFile As SQFolder & NewFileNm How do I close the "Shell.." before I run the rename script? I tried dimming Filename as variant, filename=shell... and then filename.close or quit, but I got an object error. Basically I want to take a file (could be a pdf, tif, or xfdl), rename it and save it to a different folder. And don't want to have to go back and delete it once done. Any help or suggestions would be greatly appreciated. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close Shell
I don't think you can in "straight VB" as the Shell command spawns an
program independent of the program it was executed in. I guess you could use the Windows API to find the shelled window by its title text and close it with another API call. Before trying to construct all that, would making your "script" (the one that shelled out to explorer.exe) wait for the shelled out program to close (still require API function calls) and then rename it at that point? Would that be an acceptable approach? Rick "BigPig" wrote in message ... Hi All, With this script I open a file: Shell "explorer.exe " & ReNameFolder & SelectedFile Through another script I rename the file and save it in a different folder. Name ReNameFolder & SelectedFile As SQFolder & NewFileNm How do I close the "Shell.." before I run the rename script? I tried dimming Filename as variant, filename=shell... and then filename.close or quit, but I got an object error. Basically I want to take a file (could be a pdf, tif, or xfdl), rename it and save it to a different folder. And don't want to have to go back and delete it once done. Any help or suggestions would be greatly appreciated. Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close Shell
Gary''s Student,
Thank you! I probably should have spent more time thinking about it. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close Shell
Hi Rick,
You're right. I guess I was just trying to get the "shell..." to close without changing most of what I wrote. I'm going to try fso.copyfile and then go back and kill the original file. Thank you very much. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Close Shell | Excel Programming | |||
In Before Close Sub ActiveWorkBook.Close(False) repeat procedure | Excel Programming | |||
Excel shoud not close all active books when clicking close button | Excel Discussion (Misc queries) | |||
Shell can open an application, can it close an app too? | Excel Programming | |||
excel - Windows close button (x) should only close active workboo. | Setting up and Configuration of Excel |