Thread: Hide a Workbook
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Hide a Workbook

Sometimes this works and sometimes it doesn't.

You really need to be more specific here. What _exactly_ happens when it
doesn't work?

Have you tried adding a Stop just before the ActiveWindow.Visible = False to
see what happens?


--
Jim
"AnthonyJ" wrote in message
...
| With this code in a macro for Excel XP in VBA, I open an 'output' document
| and then it in turn opens a source document so that the cells can update.
I
| want to hide the source document when it opens, but leave all other Excel
| files, especially the one I just opened, unhidden. Sometimes this works
and
| sometimes it doesn't. Could anyone tell me why, or tell me if there is a
| better code to make sure I am just hiding the source document?
|
| The code in "This Workbook" object of the 'output':
|
| ' Code Purpose: When opening output (slave) document, open main to update
| the cells correctly.
| Private Sub Workbook_Open()
|
| Dim wb As Workbook
| On Error Resume Next
| Set wb = Workbooks("Workbook.xls")
| If Not wb Is Nothing Then Exit Sub
| On Error GoTo 0
| ' Freeze screen, no screen flickering during the running of the macro.
| Application.ScreenUpdating = False
| 'Opening the main document:
| Workbooks.Open "Workbook.xls"
| 'Hiding the main document:
| ActiveWindow.Visible = False
| Application.ScreenUpdating = True
| End Sub
|
| Thanks a lot!
| --
| AnthonyJ