Solved

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

Posted on 2011-02-26
3
261 Views
Last Modified: 2012-05-11
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.
Regards,

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

0
Comment
Question by:rguillermo
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 34990137
Are you doing this from vb.net 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

http://allapi.mentalis.org/apilist/SetWindowPos.shtml

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

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34990153
In fact use API SetForegroundWindow from vb6

http://allapi.mentalis.org/apilist/SetForegroundWindow.shtml

Sid
0
 

Author Closing Comment

by:rguillermo
ID: 34992986
Thank you!!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question