Custom File Extensions

Posted on Thursday 6 April 2006

Sometime it can be useful to save files with custom file extensions, such as "MyWork.mie". This allows us to filter these files out when we used the OpenFile dialog for example. It also means that we can associate that file extension with a front loader, if we are using one.

It’s very simple to save out a file with a custom extension, you just have to specify it during the save operation. I tend to stick with text formats but it is possible to use .xls file formats with custom extensions. For example

Function MakeWorkbook()

Const FILE_EXTENSION As String = ".MIE"
Dim sFileString As String

sFileString = "*" & FILE_EXTENSION
sFileString = "M.I.E data file (" & sFileString & "), " & sFileString
sFileString = Application.GetSaveAsFilename("", FileFilter:=sFileString)  'This gets the full path!
Workbooks.Add
ActiveWorkbook.SaveAs FileName:=sFileString ',FileFormat:=xlCSV   ‘ xlTextMSDOS ‘ some other file formats

End Function

Note that the underlining file type does not change.


No comments have been added to this post yet.

Leave a comment

(required)

(required)


.

Use [VBA] Your Code [/VBA], when posting code, cheers Ross x /


RSS feed for comments on this post | TrackBack URI