![]() |
Run a macro automatically on workbook open
I have a workbook which is networked. Im trying to include a macro that will automatically run when the workbook is opened in read/write format but will not run when its read only. I understand macro's but aint got a clue on how to do this if it can be done. If it can could I poss have a idiot proof guide. Many Thanks -- tweacle |
Run a macro automatically on workbook open
You could add a single line to the top of your procedu
Option Explicit Sub auto_open() If ThisWorkbook.ReadOnly Then Exit Sub 'your normal code here End Sub (or workbook_open if you used that) tweacle wrote: I have a workbook which is networked. Im trying to include a macro that will automatically run when the workbook is opened in read/write format but will not run when its read only. I understand macro's but aint got a clue on how to do this if it can be done. If it can could I poss have a idiot proof guide. Many Thanks -- tweacle -- Dave Peterson |
Run a macro automatically on workbook open
at the top menu beside File, there is an excel symbol, right click on that icon and select view codes, Now at the drop down menu where it says general, drop down the menu to select -workbook go to the next drop down menu and select -open beginning and ending code appears put your copy and paste your macro between these two lines of code for example purposes popy and paste this code in between those two lines Dim Msg As String Msg = "This is Dave's great WorkBook!!" MsgBox Msg it will end up looking like this Private Sub Workbook_Open() Dim Msg As String Msg = "This is Dave's great WorkBook!!" MsgBox Msg End Sub Once you have that right then practise butting in the code from your macro Dave -- davesexcel ------------------------------------------------------------------------ davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708 View this thread: http://www.excelforum.com/showthread...hreadid=516505 |
All times are GMT +1. The time now is 06:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com