RemoveWeb Method Example

This example removes a web from a folder. The folder and its contents remain intact, but the folder is no longer a web.

Note   You must have the web that contains the folder open.

Private Sub WebRemove()
Dim myFolders As WebFolders
Dim myFolder As WebFolder

Set myWebFolders = Webs(0).RootFolder.Folders

For Each myFolder In myFolders
 If myFolder.Name = "TempWeb" Then
  myFolder.RemoveWeb
  Exit For
 End If
Next
End Sub