Close a previously opened separate workbook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tinsr
    New Member
    • Mar 2014
    • 1

    #1

    Close a previously opened separate workbook

    I am trying to run a Macro at startup that will close a previous linked workbook (named MainMenu). I have the following code:

    Code:
    Private Sub Workbook_Open()
    Sub CloseMainMenu()
    Windows("Filename.xlsm").Activate
        ActiveWindow.WindowState = xlNormal
        ActiveWindow.Close
    
    End Sub
    If I leave as is, I receive Compile Error: expected end sub with the first line.
    If I remove the SubCloseMainMen u(), I receive an error which states Run-time error '9': Subscript out of range

    Does anyone know how to fix this code or know a better code to use? Thanks.
    Last edited by Rabbit; Mar 4 '14, 05:27 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...