Search for a specific file's extension
CreateObject is used when you don't create a reference.
However, if attempted, the inability to create the reference should
reinforce the fact that the scripting runtime is not registered.
--
Regards,
Tom Ogilvy
wrote in message
oups.com...
Hi,
That "Scripting.FileSystemObject" must be use Reference:
Microsoft Scripting Runtime
Just check your ToolsReferences commandbar of VBE
Regards,
Halim
2007-User menuliskan:
Moon!,
It gives me an error on this line :
Set fso = CreateObject("Scripting.FileSystemObject")
the error is "ActiveX component can't create objects"
Do you know why I am getting this message?
Thanks.
"moon" <6369706865725F6475646540706C616E65742E6E6C wrote in message
. ..
This should work after a buttonclick...
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal
lpDirectory
_
As String, ByVal nShowCmd As Long) As Long
Private Sub Worksheet_Button_SearchECW_Click()
Dim searchPath, ecwFile As String
Dim fso, fs, fc, f
searchPath = ThisWorkbook.Path & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fs = fso.GetFolder(searchPath)
Set fc = fs.Files
For Each f In fc
If Right(f.Name, 4) = ".ECW" Then
ecwFile = f.Name
Exit For
End If
Next f
Set f = Nothing
Set fc = Nothing
Set fs = Nothing
Set fso = Nothing
ShellExecute vbNull, vbNullString, ecwFile, vbNullString,
searchPath, 1
End Sub
"2007-User" schreef in bericht
...
Hi Guys,
I need a VBA to be able to search for a file with specific extension
(like "ecw"),
and have another application to open that file.
(search for the file can be in the same directory that the correct
open
excel file is existing)
How this is possible?
Any help would be appreciated.
|