Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to open Explore with VBA code in Excel- POSSIBLE??

Status
Not open for further replies.

MrsTFB

MIS
Oct 3, 2000
307
US
I have a macro that moves a file to a new directory. I really want to delete the file from the original folder when it is saved into the other folder. I have not been able to use the kill command because the filename will be different each time. It is based on text in a particular cell Range("B6").text. The next best thing I thought would be to move the user directly to Microsoft Explorer to delete the file manually. Haven't been able to accomplish this yet either.

Using Office97 and Win98 if that matters.

Thanks,
Bsimm
[sig][/sig]
 
You can use

Dim OpenExplore
OpenExplore = Shell("C:\Windows\Explore.exe")
AppActivate = OpenExplore
[sig][/sig]
 
I opened a new workbook. Inserted a new userform with one option button and coded the button as below:

textDim OpenExplore

Private Sub OptionButton1_Click()
OpenExplore = Shell("C:\Windows\Explore.exe")

AppActivate = OpenExplore

End Sub


It gives me an Argument Not Optional error message.

Does this mean it can't be used from an Option Button?

Thanks for any help!! :-D


 
It doesn't work because it should be:

OpenExplore = Shell("C:\Windows\Explorer.exe")

not:

OpenExplore = Shell("C:\Windows\Explore.exe")





xtreme1
rbio@excite.com

 
Going back to your original need, try this:

Dim file_to_kill as string

'create proper filename with path -- you may replace the explicit
'path and extension with other variables

file_to_kill = "C:\yourdirectory\"+ Range("B6").Text + ".ext"

'note: if the file is open an error will occur!!

kill file_to_kill

'============================

Much easier than involving the user via Explorer!

Roy



 
Just got around to trying this, PERFECT!!! That was exactly what I wanted. I named a string for filename also though, and pulled it from Range("e6").

Thanks for making it easier for me.

Bsimm

GO TITANS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top