×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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

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

You can use

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

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

(OP)
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!!  


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

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
 
 

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

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



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

(OP)
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!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close