Solved

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

Posted on 2011-02-26
3
258 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
Comment Utility
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
Comment Utility
In fact use API SetForegroundWindow from vb6

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

Sid
0
 

Author Closing Comment

by:rguillermo
Comment Utility
Thank you!!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now