Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
2003/2007
(This has to do with PowerPoint VBA, but I'm asking here because theres a lot more VBA users here.) Is there a way to run a batch-like command line to delete a folder from within routine 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. (Known problem with PPT.) BUT I can make the code run an external CMD file consisting of "RMDIR C: \foldername /s /q" and it works fine. The problem is, I'd rather not use an external file. Is there another way to call it from within the routine but use some sort of Shell command or something (without using an external file)? Thanks, Melina |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() the VBA kill method will delete a file if it is not being used by any process running. so you first must close the file to remove the object. Kill pathname the filename can include a path as well as the file name Kill c:\temp\myslideshow.ppt Kill c:\temp\myworkbook.xls Kill c:\temp\mytexfile.txt -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=186199 Excel Live Chat |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Right. It is closed. It's a .PPA addin that code unloads and removes
from PowerPoint, just as code can do with an .XLA in Excel. Difference is that in Excel you can then delete the XLA, whereas PowerPoint holds on to it during the running of that macro. In other words, in Excel VBA, you can unload an addin AND delete the addin file all in one routine, but not so in PowerPoint. (It's a broken design to a lot of us.) So, I have to find a way to delete it outside of normal kill calls and find aa CMD or BAT call or an API call. But I'm looking for ideas on that. -Melina On Mar 10, 3:03*am, joel wrote: the VBA kill method will delete a file if it is not being used by any process running. *so you first must close the file to remove the object. Kill pathname the filename can include a path as well as the file name Kill c:\temp\myslideshow.ppt Kill c:\temp\myworkbook.xls Kill c:\temp\mytexfile.txt -- joel |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm not much of a PPT user, but you could use your code to build the .bat file
(in the %temp% folder???), run that command, and delete the .bat file you created. Option Explicit Sub testme() Dim myBatFile As String Dim myFileNum As Long Dim myCommand As String myBatFile = "C:\deletemelater.bat" myFileNum = FreeFile Close myFileNum Open myBatFile For Output As myFileNum Print #myFileNum, "RMDIR C: \foldername /s /q" Close myFileNum myCommand = Chr(34) & myBatFile & Chr(34) Shell Environ("comspec") & " /k " & myCommand, vbMaximizedFocus Application.Wait Now + TimeSerial(0, 0, 10) 'let it finish Kill myBatFile End Sub Be careful when you're testing! You don't want to delete the wrong folder!!! ps. You may want to ask in a forum dedicated to VB. Maybe there's an API call (or script) you can use. Make sure you explain that you're using PPT and VBA. It may change the responses. Mel wrote: 2003/2007 (This has to do with PowerPoint VBA, but I'm asking here because theres a lot more VBA users here.) Is there a way to run a batch-like command line to delete a folder from within routine 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. (Known problem with PPT.) BUT I can make the code run an external CMD file consisting of "RMDIR C: \foldername /s /q" and it works fine. The problem is, I'd rather not use an external file. Is there another way to call it from within the routine but use some sort of Shell command or something (without using an external file)? Thanks, Melina -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to check for the existence of the Temporary folder namedTemporary Folder a , 2 and so on before deleting as the name is not fixed | Excel Programming | |||
Windows LOGON NAME - special case - account name different from folder name | Excel Programming | |||
Deleting empty rows (special case) | Excel Discussion (Misc queries) | |||
Excel VBA - deleting populated folder problem | Excel Programming | |||
Deleting Files in Folder | Excel Programming |