Form wont stay on top. How do I keep my excel form from hiding behind other windows after I browse
Posted
by ScottK
on Stack Overflow
See other posts from Stack Overflow
or by ScottK
Published on 2009-11-19T21:23:02Z
Indexed on
2010/05/30
20:02 UTC
Read the original article
Hit count: 173
I have a vb.net program that opens up an excel workbook and runs a macro ("Report") in that workbook when a button is clicked.
//Workbook with macro and form
xlWorkbook = xlApp.Workbooks.Open("W:Data\Excel Program.xls")
//Macro:
xlApp.Run("Report")
//Macro opens form from workbook. I browse for my two .csv files
//and then click a button to run code that creates my reports.
//form closes, show the excel report after its created
xlApp.Visible = True
After I browse my first file and select it so that its location is displayed in my text box, the excel form then hides behind any open windows. I want this form to stay on top.
It is after this code executes that the form will hide behind all other open windows:
Private Sub btnBrowseFile1_Click()
Dim fileName1 As String
fileName1 = Application.GetOpenFilename("CSV file (*.csv), *.csv")
If fileName1 <> "False" Then
Me.txtFileName1.text = fileName1
End If
End Sub
EDIT: I still have no luck with this problem. When the excel macro is opened from a vb program I have this hiding issue...but only after browsing for a file. Why does the focus leave the form and go to Windows after browsing a file? Any one have any suggestions?
© Stack Overflow or respective owner