Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 445 - Object doesn't support this action

Status
Not open for further replies.

ceil32

MIS
Apr 8, 2008
263
IE
I have a Macro that has always worked on previous versions of Excel (it still works on Excel 2003 & older on different clients)

When I upgraded a user to Excel 2007 and tried to run the Macro I got the error : "Run-time error 445 - Object doesn't support this action"

I know filesearch is not supported in Excel 2007 - what can I do?

Here is the code:

With Application.FileSearch

.LookIn = Worksheets("Runtime").Range("D3").Value
.SearchSubFolders = False
.Filename = Worksheets("Runtime").Range("D5").Value & "." & Worksheets("Runtime").Range("D7").Value
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles

If .Execute() > 0 Then

For i = 1 To .FoundFiles.Count
response = MsgBox("Do you want to import " & .FoundFiles(i) & "?", vbYesNoCancel, "Select Order file to import")

If response = vbYes Then ' User chose Yes.
Debug.Print "Import " & .FoundFiles(i) ' Perform some action.
vrtSelectedItem = .FoundFiles(i)
Else ' User chose No.
If response = vbNo Then
Debug.Print " Don't Import " & .FoundFiles(i) ' Perform some action.
Else
Debug.Print "Cancel selected"
End If
End If

 
Hi,

Application.FileSearch is no longer supported in Office 2007 VBA; it has been removed without replacement.

You'll have to use the Scripting FileSystemObject instead.

Cheers,
miS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
I'd either have a look into writing your own version of FileSearch using either the FileSysytemObject or the Dir() function.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
HarleyQuinn: "I'd either have a look into writing your own version of FileSearch using either the FileSysytemObject or the Dir() function."

Interesting. Any suggestions for that. Yes, some functionality can be replicated using FSO and/or Dir, but some can not.

FileSearch used behind the scene access to file contents that simply can not be duplicated, as the properties/methods are no longer exposed. Things like:

.MatchTextExactly
.PropertyTests
.SearchScopes

SearchScopes alone was worth having FileSearch. How would you duplicate msoSearchInMyNetworkPlaces within the context of FSO, or Dir? I would be delighted to learn.

How could you duplicate PropertyTests like:

Condition:=msoConditionAnytimeBetween, _
Value:="1/1/96", SecondValue:="6/1/96", _
Connector:=msoConnectorAnd

Or msoConditionBeginsWith?

I do not think it would be easy to write "your own version of FileSearch"...if possible at all. A half-assed version that - I admit - would get some of the functionality of FileSearch, but so many parameters are just no longer exposed to us...no, I can not see it. True, I know of few people who use, for example, PropertyTests, so maybe for the OP a sort-of version may be possible.

Sorry for the semi-rant.....removing FileSearch really ticked me off.

Gerry
 
Gerry,

No need to apologise, I can see it's a sore subject for quite a few people.

I agree, there are some parts of FileSearch that would be difficult to replicate fully using solely FSO or Dir() however, there is very little in the example given by the OP that would be particularly challenging to replicate (and this is where my answer was refering to rather than re-write the whole function).

However, your reply intrigues me, specifically
FileSearch used behind the scene access to file contents that simply can not be duplicated
From my reading about FileSearch (I admit, I don't use it alot so I had to read further to fully digest it's particulars) I can't see anything that FileSearch does that cannot be replicated using the FSO in conjunction with the windows API functions (or only using the API's), though as you said (and I'm sure I didn't imply to the contrary) it won't be a walk in the park.

The reason I didn't specify the API's in my original reply was that, for the OP's case, they didn't seem necessary.

It might be an interesting challenge to try and replicate fully the functionality in this way (assuming I get time I'll have a go myself. I'm not thinking this will be a quick bit of coding though), as it will not only be useful to others 'as is', it would allow people to tailor it to their needs if they didn't want the simple generic version.

Regards

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Go for it!!!! I encourage you immensely to try and do it. I will be the first to give a zillion stars if you post something truly close to duplicating it.

"I'm not thinking this will be a quick bit of coding though"

LOL.....ummmmm, no, it is not. I have been working at it for a while. Again, go for it. Share.

Yes, within the context of the OP, going down the API route was not in the cards.

I suspect though - and hey prove me wrong please! - that you will NOT be able to duplicate some things, even through API. I suspect that Microsoft does not release all functionality they use, in published API. However, this is walking into an area that I am not (in any way) expert at.

Gerry
 
I've started writing my attempt to replicate the FileSearch(), it might be a while until it's outthere but I'm looking forward to the challenge (and a zillion stars sounds good [wink]).

Microsoft does not release all functionality they use, in published API
You are correct there, however there are several undocumented (by Microsoft anyway) API's kicking around that if I truly need that functionality for correct replication I'll delve into [smile]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
[ponder]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Ah right! You'd completely lost me there... [smile]

It's not going to be done this week (I'm off for an after work drink in 2 minutes), but I'll try and get something knocked up sometime next week so everyone can pick it to bits (assuming I post source) [wink]




HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
I think strongm is being slightly amused/sarcastic - all well within the safe confines of regular tek-Tippers I think.

I do not think anything untowards was intended....although....

"get something knocked up sometime next week so everyone can pick it to bits (assuming I post source) "

Really? Next week? Well now....I am going to have to do a tum ti tum on that one, myself. I will be waiting with baited breath.

No, seriously. I know from your many other posts that you are a capable and knowledgeable programmer, so hey, maybe it will happen. But a week? Hmmmmm, no offence intended, but if I was a betting man, I would not put money on that.

And you bloody well better post source!!!! We (well, speaking for myself actually) will haunt you if you don't.

Again, seriously, if you can truly replicate FileSearch there are many people who would be very interested. I can not locate it right now, but I know there was a thread where the OP was howling because they had many procedures (used in hundreds of files) that used FileSearch and of course all of them crashed and burned in the 2007 context.

Gerry
 
Thanks for the reality check there Gerry, I think I got a bit carried away with the idea of getting this done.

I'm still going to try and get it done this week but if it's not ready by Friday I'm sure you'll understand [wink]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Reprise:

tum ti tum

[poke]

we are waiting............

Just kidding! Take your time. Have a beer. Take a walk and buy a wig to cover up the bald spots from where you have torn your hair out....

[cheers]

Gerry
 
I might have to tear someone else's hair out if it get's that tough, I'm not too keen on being bald at 27!! [tongue]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Hey it is only as tough as you are, you young whippersnapper. I have no idea what that really means.

You are pretty hot stuff, so maybe you will only need to tear a wee little tuft of hair out; a sort of badge of honour.

Meanwhile strongm and I will be chortling, off in the background.



Tum ti tum......

Gerry
 
Gerry,

Got a fair bit of this written now (annoyingly though, the speed is only very slightly faster than FileSearch(), I wanted to get a bit more out of it, but I can fine tune once the main functionality is there).

I've got a question though which I thought you might be able to help me with. When using FileSearch() if you specify a FileType (other than AllFiles) AND a FileName my testing seems to indicate that it ignores the FileType and just use the FileName. Is this the case or is it something in my testing that's going astray?

Cheers

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
AFAIK, that is correct. An explicit parameter (Filename) supercedes a generalized parameter (FileType). I believe this is normal behaviour in VBA. Some one else may correct me on that.

Gerry
 
Thanks for clearing that up Gerry.

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
hello,

same situation here as many others. Working app in 2003 but then microsoft decided to be funny and delete the file search funtcion :( Why are they doing that!

I did some searching on the net and discovered this site where someone has written an 'alternative' file search. But I can't get it workin in my project. But I think that is due to my 'programming 'skills :)
Maybe it can help you guys to write an 'easier' replacement.

grt
grob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top