I have the following code:
Private Sub ComboBox1_DropButtonClick()
Calculate
Me.ComboBox1.Clear
Dim X As String
Dim myFileSystem As Object
Dim myFolder As Object
Dim myFiles As Object
Dim myFile As Object
Const TargetFolder As String = "C:\Accts"
Const myExtension As String = "*.xls"
ComboBox1.Value = ""
ComboBox2.Value = ""
'*** this next line is where the problem is ***
Set myFileSystem = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set myFolder = myFileSystem.GetFolder(TargetFolder)
If Err <> 0 Then MsgBox "Unable to find folder.": Exit Sub
Set myFiles = myFolder.Files
For Each myFile In myFiles
If Right(LCase(myFile.Name), 4) Like myExtension Then
Me.ComboBox1.AddItem myFileSystem.GetBaseName(myFile.Name)
End If
Next myFile
Set myFolder = Nothing
Set myFileSystem = Nothing
End Sub
*** I get '429 Activex component can't create object error'
It worked fine in the past on 97, 2000 & 2002 but now doesn't so I must have done something silly!
Reading other threads on the subject refer to making a Reference to 'Microsoft Scripting Runtime'. I don't recall making a Reference to 'Microsoft Scripting Runtime' before and can't find it in the list.
In another thread it refers to SCRRUN.DLL and I have this in system32.
What on earth am I missing?
Private Sub ComboBox1_DropButtonClick()
Calculate
Me.ComboBox1.Clear
Dim X As String
Dim myFileSystem As Object
Dim myFolder As Object
Dim myFiles As Object
Dim myFile As Object
Const TargetFolder As String = "C:\Accts"
Const myExtension As String = "*.xls"
ComboBox1.Value = ""
ComboBox2.Value = ""
'*** this next line is where the problem is ***
Set myFileSystem = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set myFolder = myFileSystem.GetFolder(TargetFolder)
If Err <> 0 Then MsgBox "Unable to find folder.": Exit Sub
Set myFiles = myFolder.Files
For Each myFile In myFiles
If Right(LCase(myFile.Name), 4) Like myExtension Then
Me.ComboBox1.AddItem myFileSystem.GetBaseName(myFile.Name)
End If
Next myFile
Set myFolder = Nothing
Set myFileSystem = Nothing
End Sub
*** I get '429 Activex component can't create object error'
It worked fine in the past on 97, 2000 & 2002 but now doesn't so I must have done something silly!
Reading other threads on the subject refer to making a Reference to 'Microsoft Scripting Runtime'. I don't recall making a Reference to 'Microsoft Scripting Runtime' before and can't find it in the list.
In another thread it refers to SCRRUN.DLL and I have this in system32.
What on earth am I missing?