Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Access to Foreground After GetObject 1

Status
Not open for further replies.

wemeier

IS-IT--Management
Aug 15, 2001
324
US
I am opening an Excel spreadsheet using the GetObject function. In order to reference the cells, I need to make Excel and the spreadsheet visible. When I do this, Excel moves to the foreground and Access moves to the background. I've tried to use SetFocus and Visible, but neither brings Access back to the foreground. Does anyone know of a VBA command to move Access back to the foreground? Or do I have to use a Windows API to do it?

[shadeshappy] Cruising the Information Superhighway
(your mileage may vary)
 
use Windows("Databasename.mdb").activate

To go where no programmer has gone before.
 
Hi wemeier,

You do not need to make it visible to reference the cells via code. You only need to make it visible if you want the User to be able to interact with it, in which case the foreground is where it must be, and when you have done with that interaction you can hide the application. If you do give a User full access to do things in the middle of your process, of course, you need to check what they have done (closed Windows, for example) when you resume.

Enjoy,
Tony
 
Tony,

Unfortunately, I DO seem to have to make the worksheet visible in order to reference the cells. If I don't make the application and/or worksheet visible, I get:

Error#1004: Method 'Cells' of object '_Application' failed.

when I try to access a cell's value (using .Cell.Value). As soon as I make the worksheet visible, the error goes away.


[shadeshappy] Cruising the Information Superhighway
(your mileage may vary)
 
dbsqared,

Thanks for the try, but Windows.Activate seems to be for Excel workbooks only, not for Access databases. When I tried to put it into my Access VBA coding, I got an error that the Window subscript was out of range or not found. When I displayed Windows.Count it came back with zero!


[shadeshappy] Cruising the Information Superhighway
(your mileage may vary)
 
Eureka! Thanks to dbsquared's suggestion, I did some more digging and found the AppActivate function. This function will activate the named window. I put it into my application and it works great!

Thanks to all who tried to help.

[shadeshappy] Cruising the Information Superhighway
(your mileage may vary)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top