I have a winform on my excel application that has a button to minimize the form. But I also want to minimize the Excel application as well, which is already open. I worked out the code below, but is telling me that my variable is used before being assigned a value.
Here is my code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim xl As Excel.Application
Me.WindowState = FormWindowState.Minimized
xl.Application.WindowState = XlWindowState.xlMinimized
End Sub