Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to develop an application in VB.net that will take a .WK1
file and save it as a .csv or .txt file. It was suggested that somebody on this board may be able to show me how to do it using VB in Excel, and then someone on the VB.Net board can convert that to .NET. I know this sounds terribly convoluted, but if anyone can tell me how, in Excel, I can programmaticaly open a .WK1 file and then save it as a ..csv file, I would be eternally grateful. Thanks, Sara |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |