Microsoft Office Forums


Reply
Thread Tools Display Modes

VBA- Deleting a file problem...

 
 
Mel
Guest
Posts: n/a

 
      03-10-2010, 07:09 AM
'Anyone know of a way to run a command line from within PPT without
calling to an external BAT or CMD file? I'm trying to simply delete
some folders within which is an addin that my code already unloaded
and removed and unregistered, and now I want its folders deleted
(within the same PPT session that started the macro). But PPT holds on
to the addin file thinking it's still being used (which it's not) and
won't let RmDir or Kill code remove it. BUT I can make it run a CMD
file consisting of "RMDIR C:\foldername /s /q" and it works fine. The
problem is due to technicalities, I'd rather not use an external file.
Is there another way?

Thanks,
Melina
 
Reply With Quote
 
 
 
 
Karl E. Peterson
Guest
Posts: n/a

 
      03-11-2010, 12:14 AM
Mel wrote:
> 'Anyone know of a way to run a command line from within PPT without
> calling to an external BAT or CMD file? I'm trying to simply delete
> some folders within which is an addin that my code already unloaded
> and removed and unregistered, and now I want its folders deleted
> (within the same PPT session that started the macro). But PPT holds on
> to the addin file thinking it's still being used (which it's not) and
> won't let RmDir or Kill code remove it. BUT I can make it run a CMD
> file consisting of "RMDIR C:\foldername /s /q" and it works fine. The
> problem is due to technicalities, I'd rather not use an external file.
> Is there another way?


Amazing that RMDIR works! But, if it does, you don't *have* to run it
via a CMD file. You can just do something like:

Dim cmd As String
cmd = "RMDIR C:\foldername /s /q"
Shell Environ("comspec") & " /c " & cmd

Something like that, at any rate...

--
..NET: It's About Trust!
http://vfred.mvps.org


 
Reply With Quote
 
Mel
Guest
Posts: n/a

 
      03-26-2010, 02:44 AM
Wow, that was too easy, Karl! I tested it and it worked. There was no
need to use an external CMD file. That seems too easy, but I love it.

Can anyone think of drawbacks or gotcha's for doing it that way?

And what's the difference in these two ways of coding it?

Shell Environ("comspec") & " /c " & cmd

Call Shell (Environ$ ("COMSPEC") & " /c " & cmd)

Thanks,
Melina


On Mar 10, 8:14*pm, Karl E. Peterson <k...@exmvps.org> wrote:
>
> Amazing that RMDIR works! But, if it does, you don't *have* to run it
> via a CMD file. You can just do something like:
>
> Dim cmd As String
> cmd = "RMDIR C:\foldername /s /q"
> Shell Environ("comspec") & " /c " & cmd
>
> Something like that, at any rate...


> Mel wrote:
> > 'Anyone know of a way to run a command line from within PPT without
> > calling to an external BAT or CMD file? I'm trying to simply delete
> > some folders within which is an addin that my code already unloaded
> > and removed and unregistered, and now I want its folders deleted
> > (within the same PPT session that started the macro). But PPT holds on
> > to the addin file thinking it's still being used (which it's not) and
> > won't let RmDir or Kill code remove it. BUT I can make it run a CMD
> > file consisting of "RMDIR C:\foldername /s /q" and it works fine. The
> > problem is due to technicalities, I'd rather not use an external file.
> > Is there another way?

 
Reply With Quote
 
Karl E. Peterson
Guest
Posts: n/a

 
      03-29-2010, 09:19 PM
Steve Rindsberg wrote:
>> Can anyone think of drawbacks or gotcha's for doing it that way?

>
> You need to be aware that once you launch a process with SHELL, the rest of
> your code continues to run.


Of course, but that's the same proposition he was facing originally,
right? There are a lot of ways you can do a "shell and wait" routine,
if that's needed, though.

--
..NET: It's About Trust!
http://vfred.mvps.org


 
Reply With Quote
 
Karl E. Peterson
Guest
Posts: n/a

 
      03-29-2010, 09:23 PM
Mel wrote:
> Wow, that was too easy, Karl! I tested it and it worked. There was no
> need to use an external CMD file. That seems too easy, but I love it.
>
> Can anyone think of drawbacks or gotcha's for doing it that way?


Like Steve pointed out, it's asynchronous, so if you have multiple
commands that each depend on the previous one being completed first,
you'll need to start looking at that CMD file again. Or, look for
"shell and wait" algorithms. (http://vb.mvps.org/samples/Shell32)

--
..NET: It's About Trust!
http://vfred.mvps.org


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Excel file without server access Alex Access Newsgroup 3 03-17-2010 12:16 PM
password protection - saving as same file name; & deleting. PG Project Newsgroup 7 03-03-2010 06:11 AM
Can't Open Outlook Ralph Outlook Newsgroup 35 03-01-2010 04:30 PM
PowerPoint automation problem Wolfgang PowerPoint Newsgroup 0 02-21-2010 03:29 PM
Baseline work does not roll up correctly jgyap Project Newsgroup 19 02-18-2010 08:25 PM



All times are GMT. The time now is 02:08 PM.