GetOpenFilename: FileFilter syntax for Excel Mac 2004

K

kirin

Hello,

Looking for some help here. I am running Pather with Excel Mac 200
(11.2). I am prompting the user to select a file to open, and want t
restrict the file type to Excel spreadsheets with the filefilte
command.

I have tried:
X=application.getopenfilename( _
filefilter="XLS")

I have also tried
X=application.getopenfilename( _
filefilter="Microsoft Excel (*.xls),*.xls*)

Neither works. Does anyone know what the file filter code for any ol
excel file is when using VB for Mac
 
J

JE McGimpsey

kirin said:
Looking for some help here. I am running Pather with Excel Mac 2004
(11.2). I am prompting the user to select a file to open, and want to
restrict the file type to Excel spreadsheets with the filefilter
command.

I have tried:
X=application.getopenfilename( _
filefilter="XLS")

I have also tried
X=application.getopenfilename( _
filefilter="Microsoft Excel (*.xls),*.xls*)

Neither works. Does anyone know what the file filter code for any old
excel file is when using VB for Mac?

Did you look at Help?
FileFilter Optional Variant. A string specifying file filtering criteria.

On the Macintosh, this string is a list of comma-separated file type codes
(for example, "TEXT,XLA5,XLS4"). Spaces are significant and shouldn't be
inserted before or after the comma separators unless they're part of the file
type code. If omitted, this argument defaults to all file types.

So you need to use the 4-character type code.

However, type codes are only generated on Macs, and OS X files don't
require them. I've given up using the filefilter argument altogether.
 
B

Bob Greenblatt

Hello,

Looking for some help here. I am running Pather with Excel Mac 2004
(11.2). I am prompting the user to select a file to open, and want to
restrict the file type to Excel spreadsheets with the filefilter
command.

I have tried:
X=application.getopenfilename( _
filefilter="XLS")

I have also tried
X=application.getopenfilename( _
filefilter="Microsoft Excel (*.xls),*.xls*)

Neither works. Does anyone know what the file filter code for any old
excel file is when using VB for Mac?
In addition to JE's recommendations, I'd also like to point out that if the
user uses the disclosure triangles to drill into folders, getopenfilename is
likely to return an incorrect path to the file. This is a reported bug that
Microsoft is aware of. The workaround is to have the user double click the
folders rather than use the disclosure triangles. There is no way to enforce
this via code.
 
K

kirin

Hmmm. Thanks for the pointers. I did look in help and saw the sam
instructions, However, I've tried XLS4 through XLS9, XCEL, etc., an
all excel files in my folders remain greyed out in the file selectio
dialog. I know this is elementary but I'm just not getting it to work
Is there a way to determine what "file code" an excel file is or, an
recommendations for error checking whether the document type is correc
w/o using the filefilter commands
 
J

JE McGimpsey

kirin said:
Hmmm. Thanks for the pointers. I did look in help and saw the same
instructions, However, I've tried XLS4 through XLS9, XCEL, etc., and
all excel files in my folders remain greyed out in the file selection
dialog. I know this is elementary but I'm just not getting it to work!
Is there a way to determine what "file code" an excel file is or, any
recommendations for error checking whether the document type is correct
w/o using the filefilter commands?

Since XL98, the default XL file format has been XLS8. Using this code
works for me in XLv.X and XL04, using Mac OS X 10.4.3.

Many applications are available that read/modify the File Type and
Creator codes. Check with VersionTracker (http://versiontracker.com).
 
P

Paul Berkowitz

Since XL98, the default XL file format has been XLS8. Using this code
works for me in XLv.X and XL04, using Mac OS X 10.4.3.

Many applications are available that read/modify the File Type and
Creator codes. Check with VersionTracker (http://versiontracker.com).

You could use

set xcelFile to MacScript("(choose file of type {""XLS8""}) as string")
xcelFile.Open

or similar. If you want to allow more file types (such as text csv files)
just add them in:

set xcelFile to MacScript("(choose file of type {""XLS8"", ""TEXT""}) as
string")
xcelFile.Open



This will work for files saved in Excel Mac, which always assign file and
creator types, but it won't work for .xls, .csv files saved in Excel on a
Windows PC and brought over directly without passing through Excel Mac.
There is supposed to be a new way of including files without file types,
hopefully via extension - I'm looking into it.


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
P

Paul Berkowitz

This will work for files saved in Excel Mac, which always assign file and
creator types, but it won't work for .xls, .csv files saved in Excel on a
Windows PC and brought over directly without passing through Excel Mac.
There is supposed to be a new way of including files without file types,
hopefully via extension - I'm looking into it.
This will work for .xls files from both Mac and Windows:

set xcelFile to MacScript("(choose file of type
{""com.microsoft.excel.xls""}) as string")
xcelFile.Open

There's no way (yet) to get .csv files from Windows.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
J

JE McGimpsey

Paul Berkowitz said:
This will work for .xls files from both Mac and Windows:

set xcelFile to MacScript("(choose file of type
{""com.microsoft.excel.xls""}) as string")
xcelFile.Open

There's no way (yet) to get .csv files from Windows.

That's nice, Paul, I could use it in my cross-platform apps. Do you know
if it works for all OS X versions?
 
P

Paul Berkowitz

That's nice, Paul, I could use it in my cross-platform apps. Do you know
if it works for all OS X versions?

Unfortunately not - only Tiger. 'type identifiers' were added (to the
previous 4-character file types) as an allowable type for the 'of type'
parameter of 'choose file' only with OS 10.4.0. 'type identifiers'
themselves are pretty recent (Panther, OS 10.3) too:

<http://developer.apple.com/documentation/Carbon/Conceptual/understanding_ut
is/understand_utis_intro/chapter_1_section_1.html#//apple_ref/doc/uid/TP4000
1319-CH201>

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
Top