Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1843
  • Last Modified:

Autoopen macros in Excel and VBA?

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
0
lewisant
Asked:
lewisant
  • 2
  • 2
1 Solution
 
Dave BrettVice President - Business EvaluationCommented:
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
0
 
Steve KnightIT ConsultancyCommented:
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.

hth

Steve
0
 
Steve KnightIT ConsultancyCommented:
Hi Dave :-)
0
 
lewisantAuthor Commented:
cheers mate that worked a treat!!!!!!!!

Anthony
0
 
Dave BrettVice President - Business EvaluationCommented:
lol - hi Steve
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now