Hey everyone,
My question is that I saved a file in vb.net to excel using the SaveFileDialog and now I want to launch the excel program and open that file after the user saves it. Can anyone help me with this? Thank you in advance. Some of my code is below. I was thinking about doing it with a temporary file name such as highlighted below my code.
Dim fn As String = My.Computer.FileSystem.GetTempFileNameCode:Dim oExcel As Object Dim oBook As Object Dim oSheet As Object oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Add oSheet = oBook.Worksheets(1) ''Save To Excel Dim sfd As New SaveFileDialog() sfd.FileName = mTitle sfd.Filter = "*.xlsx|*.xlsx" 'xml sfd.ShowDialog() oBook.SaveAs(sfd.FileName()) 'Quit Excel oExcel.Quit()
My.Computer.FileSystem.WriteAllText(fn, s.ToString, False)
Dim pi As New ProcessStartInfo
pi.FileName = "Notepad.exe"
pi.Arguments = fn
pi.WindowStyle = ProcessWindowStyle.Normal
Process.Start(pi)




Reply With Quote