Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Workbook Created with Automation Is Hidden When Opened


View products that this article applies to.

This article was previously published under Q213663

↑ Back to the top


Symptoms

When you open a workbook in Microsoft Excel, the workbook window may be hidden.

↑ Back to the top


Cause

This problem will occur if all of the following conditions are true:
  • The workbook was created by automating the SaveAs method.

    -and-
  • The source workbook was opened using the GetObject method.

↑ Back to the top


Workaround

To work around the problem, use the appropriate method.

Method 1: If the Workbook Has Already Been Created

If the workbook has already been created, you must unhide it. To do this, follow these steps:
  1. On the Window menu, click Unhide.
  2. In the Unhide workbook list, click your workbook, and then click OK.
  3. On the File menu, click Save.
The workbook will not be hidden the next time you open it.

Method 2: Change the Visual Basic for Applications Code

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: To work around the problem, you can add a line of code to the Visual Basic for Applications code that was used to create the workbook. The new line of code will unhide the workbook window before it is saved. The following example illustrates the line of code necessary to accomplish this:
Sub AutomationTest()
    Dim xlworkbook As Object
    ' Open the existing file.
    Set xlworkbook = GetObject("C:\Test.xls")
    ' Set the Visible property of the workbook window to True.
    ' This will prevent the problem.
    ' Note: This will note make Excel visible during the execution
    ' of this procedure.
    xlworkbook.Parent.Windows(xlworkbook.Name).Visible = True
    With xlworkbook
        ' Save the file as a new name.
        .SaveAs "C:\TestA.xls"
        .Close
    End With
    Set xlworkbook = Nothing
End Sub
				

↑ Back to the top


Keywords: KB213663, kbprb, kbpending, kbdtacode

↑ Back to the top

Article Info
Article ID : 213663
Revision : 7
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 371