Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tech Request -- Accessing extensionless files from VBA
 
#13
Ah, okay, I see (I think) the problem.  First off, let me address one thing: VBA and VB are -identical-.  Identical in capabilities, at any rate, with the sole exception that you can't compile code in VBA.  That said, they ship with different included bits, and that's what's caught you out here.
You're using the embedded control that came with Office, it sounds like.  Which -- by design -- does not support files with no extension.  Microsoft has known about that little gotcha since 2003 and as far as I know it's still listed as 'under review', which basically means it'll never be fixed.
That said, there's no reason VBA can't access and use the built-in Windows File Open dialog (part of the Windows common dialogs) via API and provide you complete, full, accessibility.  The downside to this is that, like with any Windows API, you're going to be using significantly more code.  I can attest that it works -- I've done it -- but I'm not sure if you want to go this route.
If you do, check out Randy Birch's site (http://vbnet.mvps.org/ind...lg/filedlgsoverview.htm) for the articles about the File Open dialog.  The site is written with VB in mind, but all of the examples work in VBA, sometimes with a little bit of tweaking (not usually, though).
That said, I think a faster/easier route would be to use a batch rename.  A batch file that does the following, for example:
Quote:REN *. *.FOO
You can call this batch file from VBA quite easily:
Quote:SHELL("foo.bat")
So in your VBA code, call the batch file before you open the file dialog, and then set the file dialog to only show files of type "*.FOO".
I think this would be easier and faster than any of the other proposed solutions.  Also, if you're really keen on keeping the files intact, you can reverse the process with another batch file that renames *.FOO to plain *.
Make sense?

--sofaspud
--"Listening to your kid is the audio equivalent of a Salvador Dali painting, Spud." --OpMegs
Reply


Messages In This Thread
[No subject] - by jpub - 07-23-2010, 07:31 PM
[No subject] - by SkyeFire - 07-23-2010, 09:17 PM
[No subject] - by paladindythe - 07-24-2010, 12:35 AM
[No subject] - by Ankhani - 07-24-2010, 01:26 AM
[No subject] - by SkyeFire - 07-24-2010, 03:03 AM
[No subject] - by Kurisu - 07-24-2010, 09:23 AM
[No subject] - by Ankhani - 07-24-2010, 08:17 PM
[No subject] - by CattyNebulart - 07-25-2010, 05:01 AM
[No subject] - by Sofaspud - 07-25-2010, 08:03 AM
[No subject] - by SkyeFire - 07-25-2010, 04:44 PM
[No subject] - by LilFluff - 07-25-2010, 10:44 PM
[No subject] - by Sofaspud - 07-26-2010, 03:16 AM

Forum Jump:


Users browsing this thread: 4 Guest(s)