HOw to open a excell file from visual basic on top of all windows

Hello Experts
I need to learn how to open on top of all windows.
Does not have to stay on top.
Just needs to open on top of all windows.

The code works just fine
Only it opens in the back of all windows.

Dim appExcel As Object
  Set appExcel = CreateObject("Excel.Application")

  Dim objBook As Object
  Set objBook = appExcel.Workbooks.Add

  Dim objsheet As Object
  Set objsheet = objBook.Sheets("Sheet1")
  appExcel.Visible = True
  appExcel.WindowState = xlMaximized

Open in new window

RGuillermoProject ManagerAsked:
Who is Participating?
SiddharthRoutConnect With a Mentor Commented:
Are you doing this from or vb6 or Excel?

If you are doing this from Excel then by default it will be on top.

If you are doing this from vb6 then have a look at this link

If you are doing this from then there is a different set of code.

In fact use API SetForegroundWindow from vb6

RGuillermoProject ManagerAuthor Commented:
Thank you!!
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.