PDA

View Full Version : FileSystemObject.DeleteFolder



truckman
08-26-2004, 08:00 AM
Hello
I am having this problem.I make a folder from VBA to save the document as HTML, then after getting the images from that folder i want to delete the folder........but when i try to delete it, RunTime Error 70, Access Denied occurs... i guess its happening because the createFolder method holds it,

ne solution ?

Following is code that i am using.....

Private Sub CreateFolder()
Dim fso
Dim fol As String
fol = Application.StartupPath & "\tmpHTML"
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(fol) Then
fso.CreateFolder (fol)
End If
End Sub

Private Sub deleteFolder()
Dim fso
Dim fol As String
fol = Application.StartupPath & "\tmpHTML"
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(fol) Then
SetAttr fol, vbNormal
fso.DeleteFolder fol, True
End If
End Sub

truckman
08-26-2004, 08:29 AM
Hello
well solved it. the error was bieng generated cuz when i save the document as HTML, the ActiveDocument start pointing to the new htm file, and as it is opened , so it can't be deleted....
Solution:i saved it back to its original location as .doc and then deleted the html folder...