From: Edward on 3 Mar 2010 16:15 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? Thanks for help. -- Best regards, Edward
From: Michael Koerner on 3 Mar 2010 16:40 I believe that is by default. because you used *.ppt it will return all files where the file extension begins with ppt. -- Michael Koerner MS MVP - PowerPoint "Edward" <Edward(a)discussions.microsoft.com> wrote in message 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? > Thanks for help. > -- > Best regards, > Edward
From: Matti Vuori on 3 Mar 2010 16:43 =?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. But if you have Office version 2007 or later, this could as well be a deliberate kludge to get PPT macros to list all PowerPoint files. Or it could be just a random bug in your macro, triggered by the phase of the moon or day of the month... You ask if you are missing something. One thing is this: being ready for _anything_ when writing Office macros! No matter how the code works, don't be surprised, don't get upset, just work around it. This one is easy to handle. Just add a check for what was returned: if myfile <> "" then if lcase(right(myfile, 4)) = ".pptx" then ... or something similar...
From: Karl E. Peterson on 3 Mar 2010 16:45 Edward wrote: > Hi every one, > I use the following code to find and populate a combobox with *.ppt files > > myfile=Dir(file pathe\+"*.ppt") Okay, first off, use & to concatenate strings, rather than +. It'll save you grief down the road. > but this return not only *.ppt file but also *.pptx file ! > Anything I'm missing here? Yeah, you'll find the same thing happens if you drop to a command window. There's some ancient plumbing at work in Windows, from back in the day when 3 chars was the max for extensions. You really always need to post-process Dir results, to be sure they are what you expect. For example, if you use a ".*" extension, you'll also get directories! -- ..NET: It's About Trust! http://vfred.mvps.org
From: Edward on 3 Mar 2010 17:44 Thanks. Now that I'm sure it wasn't from my side , I can go ahead and remove *.potx files. By the way if you use myfile=Dir(file pathe\+"*.pptx") it will only return pptx file and not ppt files . However I think this is an ugly defect in Dir() function, and MS should fix this. Best regards, Edward "Karl E. Peterson" wrote: > Edward wrote: > > Hi every one, > > I use the following code to find and populate a combobox with *.ppt files > > > > myfile=Dir(file pathe\+"*.ppt") > > Okay, first off, use & to concatenate strings, rather than +. It'll > save you grief down the road. > > > but this return not only *.ppt file but also *.pptx file ! > > Anything I'm missing here? > > Yeah, you'll find the same thing happens if you drop to a command > window. There's some ancient plumbing at work in Windows, from back in > the day when 3 chars was the max for extensions. You really always > need to post-process Dir results, to be sure they are what you expect. > For example, if you use a ".*" extension, you'll also get directories! > > -- > ..NET: It's About Trust! > http://vfred.mvps.org > > > . >
|
Next
|
Last
Pages: 1 2 Prev: WHICH SOFTWARE Next: Textbox problem - text changes font size inside the box randomly ? |