Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Sub or Function not defined


I am trying to run the following code but get this error:

Compile Error: Sub or Function not defined.

Any ideas on how to fix this or why it is occurring would be greatly
appreciated.

Sub DeleteABC()
Dim FSO As Scripting.FileSystemObject
Dim FF As Scripting.Folder
Set FSO = New Scripting.FileSystemObject
Set FF = FSO.GetFolder("C:\Test") '<<< Change Folder

DoOneFolder FF, FSO
End Sub

Sub DoOneFolder(FF As Scripting.Folder, FSO As
Scripting.FileSystemObject)
Dim SubF As Scripting.Folder
Dim F As Scripting.File
For Each F In FF.Files
If StrComp(Left(F.Name, 3), "ABC", vbTextCompare) = 0 Then
Kill F.Path
End If
Next F
For Each SubF In FF.SubFolders
DoOneFolder SubF, FSO
Next SubF
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Sub or Function not defined

Do you have a reference set to the Microsoft Scripting Runtime under Tools,
references in the VBE?

--
Jim
"hurlbut777" wrote in message
...
|I am trying to run the following code but get this error:
|
| Compile Error: Sub or Function not defined.
|
| Any ideas on how to fix this or why it is occurring would be greatly
| appreciated.
|
| Sub DeleteABC()
| Dim FSO As Scripting.FileSystemObject
| Dim FF As Scripting.Folder
| Set FSO = New Scripting.FileSystemObject
| Set FF = FSO.GetFolder("C:\Test") '<<< Change Folder
|
| DoOneFolder FF, FSO
| End Sub
|
| Sub DoOneFolder(FF As Scripting.Folder, FSO As
| Scripting.FileSystemObject)
| Dim SubF As Scripting.Folder
| Dim F As Scripting.File
| For Each F In FF.Files
| If StrComp(Left(F.Name, 3), "ABC", vbTextCompare) = 0 Then
| Kill F.Path
| End If
| Next F
| For Each SubF In FF.SubFolders
| DoOneFolder SubF, FSO
| Next SubF
| End Sub
|
|

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Sub or Function not defined


Jim, I believe so. I went to toolsreferences and the Microsoft Scripting
Runtime box is checked.

"Jim Rech" wrote:

Do you have a reference set to the Microsoft Scripting Runtime under Tools,
references in the VBE?

--
Jim
"hurlbut777" wrote in message
...
|I am trying to run the following code but get this error:
|
| Compile Error: Sub or Function not defined.
|
| Any ideas on how to fix this or why it is occurring would be greatly
| appreciated.
|
| Sub DeleteABC()
| Dim FSO As Scripting.FileSystemObject
| Dim FF As Scripting.Folder
| Set FSO = New Scripting.FileSystemObject
| Set FF = FSO.GetFolder("C:\Test") '<<< Change Folder
|
| DoOneFolder FF, FSO
| End Sub
|
| Sub DoOneFolder(FF As Scripting.Folder, FSO As
| Scripting.FileSystemObject)
| Dim SubF As Scripting.Folder
| Dim F As Scripting.File
| For Each F In FF.Files
| If StrComp(Left(F.Name, 3), "ABC", vbTextCompare) = 0 Then
| Kill F.Path
| End If
| Next F
| For Each SubF In FF.SubFolders
| DoOneFolder SubF, FSO
| Next SubF
| End Sub
|
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Sub or Function not defined


Change it to late bound

Sub DeleteABC()
Dim FSO As Object
Dim FF As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FF = FSO.GetFolder("C:\Test") '<<< Change Folder

DoOneFolder FF, FSO
End Sub

Sub DoOneFolder(FF As Object, FSO As Object)
Dim SubF As Object
Dim F As Object
For Each F In FF.Files
If StrComp(Left(F.Name, 3), "ABC", vbTextCompare) = 0 Then
Kill F.Path
End If
Next F
For Each SubF In FF.SubFolders
DoOneFolder SubF, FSO
Next SubF
End Sub


--
__________________________________
HTH

Bob

"hurlbut777" wrote in message
...
I am trying to run the following code but get this error:

Compile Error: Sub or Function not defined.

Any ideas on how to fix this or why it is occurring would be greatly
appreciated.

Sub DeleteABC()
Dim FSO As Scripting.FileSystemObject
Dim FF As Scripting.Folder
Set FSO = New Scripting.FileSystemObject
Set FF = FSO.GetFolder("C:\Test") '<<< Change Folder

DoOneFolder FF, FSO
End Sub

Sub DoOneFolder(FF As Scripting.Folder, FSO As
Scripting.FileSystemObject)
Dim SubF As Scripting.Folder
Dim F As Scripting.File
For Each F In FF.Files
If StrComp(Left(F.Name, 3), "ABC", vbTextCompare) = 0 Then
Kill F.Path
End If
Next F
For Each SubF In FF.SubFolders
DoOneFolder SubF, FSO
Next SubF
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using dcount function within user-defined worksheet function pongthai Excel Programming 3 January 15th 07 09:55 AM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
User Defined Function does not appear on Function listing H.P.Hoeie, Norway Excel Programming 1 March 21st 06 10:27 AM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"