473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Close a previously opened separate workbook

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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Workbook_Open()
  2. Sub CloseMainMenu()
  3. Windows("Filename.xlsm").Activate
  4.     ActiveWindow.WindowState = xlNormal
  5.     ActiveWindow.Close
  6.  
  7. End Sub
If I leave as is, I receive Compile Error: expected end sub with the first line.
If I remove the SubCloseMainMenu(), 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.
Mar 4 '14 #1
0 842

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nonoy of Philippines | last post by:
Hello, guys... I'm just starting to develop web applications and I have this problem regarding Session objects At some parts of my application, I open modal dialog window which also opens...
0
by: Nonoy of Philippines | last post by:
I'm not sure if my 1st posting was actually posted. So, sorry if I duplicated it. For some reason, when there are previously opened IE windows before I opened the IE window that displays our...
2
by: BerkshireGuy | last post by:
I am writing an Module in Access 2000 that needs to reference an opened Excel Workbook. Lets say the workbook is called Rankings. How would I reference that workbook from within Access? Thanks
1
by: anthony | last post by:
Hi, I have a button (Button1) to open the main form. If I want to have another button to close this opened form, how do I do it without making Mainform a global variable? Thanks! Private...
2
by: Mark | last post by:
Hi, I am trying to open up a new window and then get the current url/location back from the (win_1) window and display the url in an alert box. Here is the code I am using :- <script...
3
by: ssg31415926 | last post by:
I've just had a colleague ask me this one: is it possible to close files opened (and left open) by another app, programatically? I know it must be possible because NET FILE can do it as can...
2
by: =?Utf-8?B?dGFtZWU=?= | last post by:
I have a data list of over 1,000 spare parts. I set it up with a master data list in a separate workbook and data validation works fine. I need autocomplete so I tried inserting a combo box with...
0
by: f.oualid | last post by:
Hi, Would anyone know how I could open an already opened excel workbook. I have Windows Form with a button, and when clicked it opens the spreadsheet as follows string filename =...
7
by: NeverLift | last post by:
This is probably answered elsewhere, but I've searched the Web and VBA for Excel manual, find no answers. I have a VBA-coded macro in an Excel workbook that is to open another existing workbook --...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.