I know that it's tacky to reply to your own post, but I
was able to get a great answer to this from Fergus Coon in
the
VB.NET newsgroup, and I thought that I'd post it for
anyone that was looking for an answer:
Imports System.Runtime.InteropServices
Public Module ExcelUtils
Public Const xlCsv As Integer = 6
Public Const xlNormal As Integer = -4143
Public Const xlXls As Integer = -4143 'Alias
for xlNormal
Public Sub ConvertFile (sSrcFilePath As String, _
sDestFilePath As String, xlOutputFormat As
Integer)
Dim oExcel As Excel.Application
Dim oWorkSheet As Worksheet
Try
oExcel = New Excel.Application
oExcel.Visible = True 'Optional but good
for debugging.
oExcel.Workbooks.Open (sSrcFilePath)
oWorksheet = DirectCast
(oExcel.ActiveSheet, Excel.Worksheet)
oWorksheet.SaveAs (sDestFilePath,
xlOutputFormat)
Catch
Dim Up As New Exception ("Bad file -
Uuurghh")
Throw Up
Finally
If oWorksheet Is Nothing = False Then
Marshal.ReleaseComObject (oWorksheet)
End If
If oExcel Is Nothing = False Then
oExcel.Quit
Marshal.ReleaseComObject (oExcel)
End If
End Try
End Sub
End Module
P.S Have to add MSOffice references for this to work.