LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.






 
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
Search for specific value Dean[_9_] Excel Programming 3 March 2nd 06 07:49 PM
Transformation d'images avec une extension .jpg ou .jpeg en images avec extension .bmp ou .ico imej-clavier Excel Discussion (Misc queries) 1 May 28th 05 05:52 PM
DELETING FILES FROM A FOLDER WITH SPECIFIC EXTENSION R v Deursen Excel Programming 1 May 28th 04 02:36 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Ed[_18_] Excel Programming 4 May 20th 04 02:08 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM


All times are GMT +1. The time now is 08:32 AM.

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"