PDA

View Full Version : Open a book in the background



Djblois
02-29-2008, 08:40 AM
I am currently using the code to open a workbook and get information from it. However, I want it to not be shown to the user. Can I open the book - automatically Hidden?

Set wbRef = Workbooks.Open(sWorkbookToOpen)
wbRef.Visible = False

Thank you,
Daniel

http://studenthacker.blogspot.com/

Bob Phillips
02-29-2008, 09:06 AM
Hide the window, not the book.

Djblois
02-29-2008, 09:18 AM
Thank you XLD,

That is what I was doing first. Unfortunately it shows the book in the taskbar first then hides. I don't want it to show at all. Is that possible?

Bob Phillips
02-29-2008, 09:22 AM
Not that I am aware of. Maybe set Ignore Other APplications temporarily.

Djblois
02-29-2008, 11:47 AM
Xld,

you are not talking about Application.screenupdating are you? if that isn't what you are talking about please tell me how to do that?

Daniel

Bob Phillips
02-29-2008, 11:57 AM
No I actually meant Windows in Taskbar, Tools>Options>View>Windows In Taskbar. Record a macro to get the code

Djblois
02-29-2008, 12:29 PM
I will record the marcro but how do I find that on 2007 if you know? I just checked the View Tab Ribbon and I don't see it.

Bob Phillips
02-29-2008, 12:58 PM
Click the Orange Office button

Click the Excel Options button

Select Popular from the left-hand menu pane

In the right-hand pane, click the 'Sow developer tab in the Ribbon' checkbox

record macro is then found in the Code Group of the Developer ribbon.

Djblois
02-29-2008, 01:01 PM
No, sorry I know how to record a macro in Excel 2007. I don't know how to get to Tools>Options>View>Windows in Excel 2007.

Bob Phillips
02-29-2008, 01:42 PM
Click the Orange Office button

Click the Excel Options button

Select Advancedf rom the left-hand menu pane

In the Display section of thr right-hand pane, click the 'Show all windows in the taskbar' checkbox

record macro is then found in the Code Group of the Developer ribbon

tstav
02-29-2008, 04:12 PM
Hi Djblois,
1.Create a new instance of Excel
2.DO NOT MAKE IT VISIBLE
3.Open the workbook using this instance

Sub HideOpenWorkbook()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
'xlApp.Visible = True
xlApp.Workbooks.Open "C:\1.xls"
End Sub


From then on, for anything you will want to do with this Workbook, you're going to have to be using the xlApp just like it is used in the code to open the sample Workbook.

tstav
02-29-2008, 04:34 PM
Also, remember after closing the Workbook, to remove the xlApp object because it's taking up memory

Sub HideOpenWorkbook()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open "C:\1.xls"
xlApp.Workbooks("C:\1.xls").Close False
Set xlApp = Nothing
End Sub