How to close an excel file and a power BI file using VB.net application

I have a mini app coded in VB.net. Its function is to open an excel and power bi file by clicking buttons on a windows form and close it after using it . I can successful open the file by clicking the buttons . I'm kindly requesting anyone to help me with a code that I can use to close the excel file and the power BI file by clicking on different buttons.
Here is my code for opening the files:
Public Class Form1

    Private Sub OpenDashboards_Click(sender As Object, e As EventArgs) Handles OpenDashboards.Click
        System.Diagnostics.Process.Start("C:/Application/dashboard.pbix")
    End Sub

    Private Sub OpenTracker_Click(sender As Object, e As EventArgs) Handles OpenTracker.Click
        System.Diagnostics.Process.Start("C:/Application/tracker.xlsx")
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Visible = False



    End Sub
End Class
Douglas SeyamaSystems DeveloperAsked:
Who is Participating?
 
MishaConnect With a Mentor ProgrammerCommented:
May be you should open file by Excel, but not  " System.Diagnostics.Process.Start"
For example,
 Dim xlApp As Excel.Application
            Dim xlWorkBook As Excel.Workbook
            Dim xlWorkSheet As Excel.Worksheet

            xlApp = New Excel.ApplicationClass
            xlWorkBook = xlApp.Workbooks.Open(myFile)
            xlWorkSheet = xlWorkBook.Worksheets(1)
            xlWorkBook.Close()
            xlApp.Quit()

Open in new window

if you want to close file whithout save
xlWorkBook.Close(False)

Open in new window

0
 
MishaProgrammerCommented:
There in no activity from author
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.