LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Excel 2007 file in 2003 creates very large file Jon Pearce Excel Discussion (Misc queries) 2 July 16th 09 07:20 PM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
How do I stop Excel 2000 from saving file history from file that . Cathy Excel Discussion (Misc queries) 0 March 29th 05 03:27 PM
Saving a file(new) using the multiple cell contents as a file name Dave Peterson[_3_] Excel Programming 1 August 1st 03 01:40 PM


All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"