Autoopen macros in Excel and VBA?

Posted on 2003-02-27
Medium Priority
Last Modified: 2011-10-03
I have been using an Autoopen() macro in VBA with a word document for some time now, and all works fine. I have tried this with an Excel spreasheet so that the VBA function runs automatically when the worksheet opens and cannot get the function to run. Is the Autorun() function something that only works with Word, if so is there another way to do the same thing within Excel?

Anthony Lewis
Question by:lewisant
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 50

Expert Comment

by:Dave Brett
ID: 8033917
Auto_Open () should work

alternatively from VBA help

WorkbookOpen Event Example

This example arranges all open windows when a workbook is opened.

Private Sub  App_WorkbookOpen(ByVal Wb As Workbook)
    Application.Windows.Arrange xlArrangeStyleTiled
End Sub
LVL 43

Accepted Solution

Steve Knight earned 200 total points
ID: 8033931
You need to use the Workbook_Open() event instead.  Press ALT F11 to get into the VB editor then double click into ThisWorkbook, choose Workbook from the left hand menu and you can see the events associated with a workbook.  You can put your code here...

The same goes for sheets.  Double click into Sheet1 say in the project explorer and you can see the events there in the same way.


LVL 43

Expert Comment

by:Steve Knight
ID: 8033951
Hi Dave :-)

Author Comment

ID: 8034022
cheers mate that worked a treat!!!!!!!!

LVL 50

Expert Comment

by:Dave Brett
ID: 8034032
lol - hi Steve

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question