PDA

View Full Version : Changes from vba version 6.3 to version 6.5



Maurice
03-03-2007, 07:35 AM
The following code works ok in v6.3

MyPath & BookName Dim as Strings

dim fs
Set fs = Application.FileSearch ' Sorry, this was left out originally
With fs
.Lookin = MyPath
.Filename = BookName
If .Execute = 0 Then
Msgbox "File not found"
End If
End With

Unfortunately, this fails on Version 6.5 and I have not sorted out how to trap the Error & find out what it would mean.

I would be very grateful for help on this. Thanks.

mdmackillop
03-03-2007, 08:13 AM
Hi Maurice
If Version 6.5 if Excel 2007, it appears that FileSearch (http://www.vbaexpress.com/forum/showthread.php?t=10867&highlight=filesearch+2007) is no longer supported.

Bob Phillips
03-03-2007, 10:07 AM
No appears, it isn't.

Maurice
03-03-2007, 02:13 PM
Thanks for your comments, I had a look at FileSystem on this site but I couldn't see how to find a file by name using it. I will try running in Compatibility mode as you suggest but it does seem strange to do away with such a useful tool! I left this message elsewhere on the forum by mistake - I'm still groping around.:friends:

mdmackillop
03-03-2007, 03:33 PM
Hi Maurice
I removed your other post to avoid confusion. You'll soon find your way about, I'm sure

Aussiebear
03-04-2007, 02:17 AM
No wonder we couldn't follow the conversation....

Maurice
03-04-2007, 12:10 PM
Thanks for your help
Can you please tell me how I can run compatibility mode within excel 2007 so that it runs the VBA v6.3 or have I misunderstood what you meant.

If it is not possible to run a compatibility mode then is there another piece of code that I could use to achieve the same result as FileSearch.

What I need to do is find a file by name and open it without going through the dialoge box.
Surely there must be a way to do this

Help!!!!!

mdmackillop
03-04-2007, 02:13 PM
Here's some options to look at
http://advisor.com/doc/16279

Bob Phillips
03-05-2007, 03:46 AM
Thanks for your help
Can you please tell me how I can run compatibility mode within excel 2007 so that it runs the VBA v6.3 or have I misunderstood what you meant.

If it is not possible to run a compatibility mode then is there another piece of code that I could use to achieve the same result as FileSearch.

What I need to do is find a file by name and open it without going through the dialoge box.
Surely there must be a way to do this

Help!!!!!

Compatibility mode means treating a workbook as if it were being processed in Excel 2003, i.e. reduced functionality, it does not mean run in a 2003 emulator. In other words, lost functionality is not restored, not in Excel, not in VBA.

You need to use a different approach for lost functions such as FileSearch, such as FileSystemobject, or the Dir function. Look them up.

Maurice
03-05-2007, 01:38 PM
Thank you all, I will try xld's suggestiom of FileSystemobject or Dir function first. Hopefully that will sort me out.

Maurice
03-07-2007, 01:15 PM
Thanks, once again for all your help. I firmed up on your suggestions by looking at the knowledge base and found the answer in "Determine if a file exists using the File System Object (FSO) submitted by xCav8r and tested on Ver. 2003. The good news is that it seems to work on Ver 2007 as well! I am now looking for a Solved smilie, so here goes!
:thumb Hopefully that will do the trick although I zoomed straight past it at first but found it on the way back.

mdmackillop
03-07-2007, 03:20 PM
Hi Maurice,
Glad you got sorted out.
You can mark your thread solved in the Thread Tools dropdown