Hello,
I have this section of code that is in a btnRun_Click Event and the code is attempting to take an excel spread sheet take the ranges of data which is currently about 5 columns with the word ‘test’ on the first row of each column and export it as a Pipe Delimited text file. The code I have doesn’t produce any errors at all but it will not produce any kind of new file. Does this look right? Thanks for any help or advice.
Code:Imports Excel3 = Microsoft.Office.Interop.Excel Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim xlApp As Excel3.Application Dim xlWorkBook As Excel3.Workbook Dim xlWorkSheet As Excel3.Worksheet Dim misValue As Object = System.Reflection.Missing.Value xlApp = New Excel3.Application xlWorkBook = xlApp.Workbooks.Open("C:\Documents and Settings\ramey.channell\My Documents\tryme.xlsx") xlWorkSheet = DirectCast(xlWorkBook.Sheets("Sheet1"), Excel3.Worksheet) xlWorkSheet.Select() xlWorkSheet.UsedRange.Copy() IO.File.WriteAllText("filename", Clipboard.GetText.Replace(vbTab, "|")) End Sub




Reply With Quote