Excel File format List

  • Thread starter Thread starter Douglas Lund
  • Start date Start date
D

Douglas Lund

I'm coding export functionality into my VB6 app, which incorporates an
excel file export, for which I use the Microsoft Excel 9.0 object
library. I would like to display the excel file formats available to
the user in a combo box.

How can I get a list of available formats at runtime ?
 
Douglas

Try this function:

'returns an array of strings containing descriptions of the possible save as options
Private Function AllSaveAsOptions() As Variant

Dim ret_val() As String
Dim fdfs As FileDialogFilters
Dim this_fdf As Long

'Set the FileDialogFilters collection variable to
'the FileDialogFilters collection of the SaveAs dialog box.
Set fdfs = Application.FileDialog(msoFileDialogSaveAs).Filters

'make the array big enough
ReDim ret_val(fdfs.Count)

'Iterate through the description and extensions of each
'default filter in the SaveAs dialog box.
For this_fdf = 1 To fdfs.Count
ret_val(this_fdf) = fdfs.Item(this_fdf).Description
Next fdf

'and return the array
AllSaveAsOptions = ret_val
End Function

Hope that helps.

Iain
 
Douglas

Try this function:

'returns an array of strings containing descriptions of the possible save as options
Private Function AllSaveAsOptions() As Variant

Dim ret_val() As String
Dim fdfs As FileDialogFilters
Dim this_fdf As Long

'Set the FileDialogFilters collection variable to
'the FileDialogFilters collection of the SaveAs dialog box.
Set fdfs = Application.FileDialog(msoFileDialogSaveAs).Filters

'make the array big enough
ReDim ret_val(fdfs.Count)

'Iterate through the description and extensions of each
'default filter in the SaveAs dialog box.
For this_fdf = 1 To fdfs.Count
ret_val(this_fdf) = fdfs.Item(this_fdf).Description
Next fdf

'and return the array
AllSaveAsOptions = ret_val
End Function

Hope that helps.

Iain
 
OP said: Microsoft Excel 9.0 object

Which is Excel 2000.

I believe Iain's solution would only work in xl2002 and later.
 
OK, Thanks Tom.
Is there any way to do it using Excel 2000 object ?
If not, am I able to redistribute the Excel 2002 object to clients
without Excel 2002?
 
Back
Top