From: Karl E. Peterson on
Matti Vuori wrote:
> =?Utf-8?B?RWR3YXJk?= <Edward(a)discussions.microsoft.com> wrote in
> news:7CAEDF5E-0C71-443B-9F25-DB163C2739DC(a)microsoft.com:
>> Hi every one,
>> I use the following code to find and populate a combobox with *.ppt
>> files
>>
>> myfile=Dir(file pathe\+"*.ppt")
>>
>> but this return not only *.ppt file but also *.pptx file !
>> Anything I'm missing here?
>
> This is surprising. Have you checked how your code works with other
> suffixes, for example does "*.do" also return .doc files? If it does,
> your version of VBA (and/or Windows) has a bug.

No, it's just the way Windows has been, ever since Win95. Actually, NT
3.5x probably acted this way too, but I'm too lazy to test. Try this:

D:\Docs\PowerPoint>copy con temp.pptx
adsf
^Z
1 file(s) copied.

D:\Docs\PowerPoint>dir *.ppt
Volume in drive D has no label.
Volume Serial Number is FA0F-40AB

Directory of D:\Docs\PowerPoint

02/23/2010 03:36 PM 82,432 CitizenCommunications.ppt
08/01/2000 08:28 AM 25,600 pptEvent.ppt
03/03/2010 03:17 PM 6 temp.pptx
3 File(s) 108,038 bytes
0 Dir(s) 739,961,786,368 bytes free

D:\Docs\PowerPoint>

(I had to actually create a file with the PPTX extension, as I don't
use that version. That's why it's so small.)

Anyway, you see, this is just the way Windows works. Basically, if you
hand it a 3-character extension, it appends an asterisk to it.

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Karl E. Peterson on
Edward wrote:
> By the way if you use myfile=Dir(file pathe\+"*.pptx") it will only return
> pptx file and not ppt files .

Right. That's the essential algorithm, near as I can tell. Windows
only appends the undesired asterisk when you hand it a 3-character
extension.

> However I think this is an ugly defect in Dir() function, and MS should fix
> this.

The defect is actually in the FindFirstFile and FindNextFile API
functions.

--
..NET: It's About Trust!
http://vfred.mvps.org