#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Close Shell

Gary''s Student,

Thank you! I probably should have spent more time thinking about it.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default 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
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
Close Shell CanonChris Excel Programming 1 June 19th 07 07:09 PM
In Before Close Sub ActiveWorkBook.Close(False) repeat procedure [email protected] Excel Programming 5 September 26th 06 03:11 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
Shell can open an application, can it close an app too? quartz[_2_] Excel Programming 4 April 26th 05 03:30 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


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