vba - opening workbooks without showing

andyjames

Board Regular
Joined
May 15, 2007
Messages
133
I have some code during which I open a workbook. however I do not want to show the workbook. i have tried getting both screenupdating and displayalerts to false but no success. can anyone help?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Dim filetoopen As Variant
Dim opeenbook As Workbook

filetoopen = Application.GetOpenFilename(Title:="Browse For Your File", FileFilter:="Excel Files(*.xlsx),*xls*")

If filetoopen <> False Then
Set openbook = Application.Workbooks.Open(filetoopen)
openbook.Visible = False

why this code didn't work
 
Upvote 0
Best solution i've seen. Actually opens workbooks without showing, (unlike the answers which claim to, but actually open it visible and hide it after).

VBA Code:
Sub test()
          GetObject "C:\MyFile.xlsx" 'Workbook will remain invisible, no new window appears in the screen
End Sub

You can get the workbook object too, if you need it:

VBA Code:
Sub test()
          Dim wb As Workbook
          Set wb = GetObject("C:\MyFile.xlsx") 
          Debug.Print wb.Worksheets(1).Name
          wb.Close
          Set wb = Nothing
End Sub

The only visible activity during the open is the standard progress-bar on lower right while opening. That can be eliminated with `ScreenUpdating=false` before the `GetObject` line.

The second best solution is for VBA to open a separate instance of Excel (using `GetObject`), and open your workbook inside that instance.
 
Upvote 0
The second best solution is for VBA to open a separate instance of Excel (using `GetObject`), and open your workbook inside that instance.
i think you would do CreateObject to open the separate instance of Excel.
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,541
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top