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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set focus to embedded excel

Status
Not open for further replies.

ninjamyst

Programmer
Jan 28, 2005
21
US
I embedded Excel into a visual basic application and I want to know how to set focus back to Excel after Excel loose focus. My problem is that I disabled all the Excel toolbars and menus so only the worksheet shows up. I also protected the worksheet from editing. I have some controls on my form that when a control (such as a treeview) is clicked, I want to switch focus to Excel so users can start scrolling right away. Also, when someone click anywhere on the worksheet, I want to activate the scrollbars. Right now, the only way to get scrollbar to work is by double clicking a cell, which generates an error message because of the protection. I have searched through the forum and faqs, and the solution of AppActivate does not work for me.

Here's what I have tried so far:
1. AppActivate("Microsoft Excel") but I get error for invalid procedure call or argument. I guess this is because I am using an embedded Excel.
2. Me.Controls(mExcelApp).SetFocus with mExcelApp declared as WithEvents Excel.Application . That didn;t work either.
3. mExcelWorksheet.Select, mExcelWorksheet.Activate

Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top