Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-01-2010
Member
 
Join Date: Dec 2009
Posts: 67
Procedure to create Auto-Run Macro

Hi All,

I know how to create the simple macros in Microsoft word and excel. Now I want to create the Auto-Run Macro. It means the the macro should run automatically when you open the particular excel sheet or word file. What should I have to to for this. Do you know how to create Auto-Run Macro? Your help will be greatly appreciable. I am waiting for your reply.
Reply With Quote
  #2  
Old 07-01-2010
Member
 
Join Date: Apr 2008
Posts: 4,641
Re: Procedure to create Auto-Run Macro

DO the following steps to create Auto-Run Macro:
  • First you need to open a new workbook, and then you need to start the Visual Basic Editor .
  • Then you need to press 'CTRL+R' for switching to the Project Explorer window.
  • Then Right click on the "ThisWorkbook object" option and then click on "View Code".
  • Then type below code in the module:
Quote:
Private Sub Workbook_Open()
Msgbox Date1

Worksheets("SheetD1").Range("DA1").Value = Date1
End Sub
  • Then again you need to switch to Excel and then save the workbook.
  • Finally Close and then reopen the workbook, then excel will run the the created macro automatically.
Reply With Quote
  #3  
Old 07-01-2010
Member
 
Join Date: May 2008
Posts: 4,565
Re: Procedure to create Auto-Run Macro

Hi,

You should first open the excel sheet for which you want to apply Auto-Run Macro. Then make Right click on the sheet tab and then you need to paste following two event codes in it:
code1:
Quote:
Private Sub Worksheet_Activate()
Name of macro
End Sub
code2:
Quote:
Private Sub Worksheet_Deactivate()
Name of macro
End Sub
Reply With Quote
  #4  
Old 07-01-2010
Member
 
Join Date: May 2008
Posts: 4,339
Re: Procedure to create Auto-Run Macro

Hello Friend,

According to me there is only one event available in the Microsoft excel and it is 'Workbook_Open event' of the Microsoft Excel to create Auto-Run Macro. The " Workbook_Open" event of excel is a built-in workbook event. This event is useful to run the code of macro on each and every time when you open the workbook.
If you you to know more about the Procedure required create Auto-Run Macro, then please visit below given link:
http://support.microsoft.com/kb/265113
Reply With Quote
  #5  
Old 07-01-2010
Member
 
Join Date: May 2008
Posts: 4,829
Re: Procedure to create Auto-Run Macro

Hi friend,

If you want to run the macro whenever you open the you desired excel file. For this you need to put the name of your macro into the "Worksheet_Activate()" event. And this code will run your macro at the opening of your excel file. I have tried this event and see following it's example"
Quote:
Private Sub Worksheet_Activate()
asd // put the name of macro here
End Sub
Reply With Quote
  #6  
Old 07-01-2010
Member
 
Join Date: Apr 2008
Posts: 4,086
Re: Procedure to create Auto-Run Macro

To create Auto-Run Macro, open event of a workbook and follow below steps:
  1. First right click on the Excel icon which is next to File over the main toolbar.
  2. Then choose 'Workbook' from the drop-down option.
  3. Then you can see the below code:
    Quote:
    Private Sub Workbook_Open()

    End Sub
  4. Here you can put any code that you want to run when you open the workbook
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Procedure to create Auto-Run Macro"
Thread Thread Starter Forum Replies Last Post
How to Create Macro in VBA program? Bigga Lexx Software Development 5 23-01-2010 06:22 PM
Procedure to create a PPS file Sarfaraj Khan Windows Software 5 11-01-2010 02:16 PM
How can I create a macro in microsoft PowerPoint? Prashobh Mallu Windows Software 5 05-01-2010 02:09 PM
How to create, deploy and use DB2 stored procedure garfield1 Software Development 3 08-08-2009 11:10 AM
How to create a macro in Excel Bhadrak Windows Software 3 06-05-2009 03:13 PM


All times are GMT +5.5. The time now is 03:59 PM.