Home |
Search |
Today's Posts |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving a WK1 file as a .CSV (or something)
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. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saving Excel 2007 file in 2003 creates very large file | Excel Discussion (Misc queries) | |||
Saving worksheet in new file with date AND cell value as file name | Excel Discussion (Misc queries) | |||
Excel should let me sort the file directory when saving a file | Excel Discussion (Misc queries) | |||
How do I stop Excel 2000 from saving file history from file that . | Excel Discussion (Misc queries) | |||
Saving a file(new) using the multiple cell contents as a file name | Excel Programming |