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

excel reference - hide workbook

Status
Not open for further replies.

fishysheep

Programmer
Oct 13, 2001
54
GB
Hi

vb project with excel reference. One instance of excel app with two workbooks. Want to hide (on task bar) one of the workbooks. Must be possible as all I'm trying to do is to mimic clicking Windows | Hide from the Excel menu.

I've sort of solved it by having two instances of Excel and opening one workbook in each and then hiding one of the Excel apps - but surely it must be possible to just hide a workbook?

thanks
 
its not an approach i would recommend but...

Code:
Dim oExcel as object
......
Set oExcel = CreateObject("Excel.Application")
'open a workbook
oExcel.IgnoreRemoteRequests = True
'open a new workbook
....

will force the second workbook you open, to open in a new instance of excel. and if i remember correctly will be invisible.

(dont quote me on this, its midnight and ill check for sure tomorrow)

i must stress that you set IgnoreRemoteRequests = False before your app closes though!

If somethings hard to do, its not worth doing - Homer Simpson
 
Assuming that excel application object reference is xlApp, workbook name is "SampleBook.xls" and it is open in one window:
xlApp.Workbooks("SampleBook.xls").Windows(1).Visible=False

combo
 
fishysheep - a very useful way to work with Excel from VB is to record an Excel macro of you doing what you want to do (in this case hiding the workbook) and then porting the created code over to your VB project.

If you do that for this case you get something that is not 1 million miles away from combo's answer.

Hope this helps

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top