Results 1 to 6 of 6

Thread: Procedure to create Auto-Run Macro

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    4,642

    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:

    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.

  3. #3
    Join Date
    May 2008
    Posts
    4,570

    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:
    Private Sub Worksheet_Activate()
    Name of macro
    End Sub
    code2:
    Private Sub Worksheet_Deactivate()
    Name of macro
    End Sub

  4. #4
    Join Date
    May 2008
    Posts
    4,345

    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

  5. #5
    Join Date
    May 2008
    Posts
    4,831

    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"
    Private Sub Worksheet_Activate()
    asd // put the name of macro here
    End Sub

  6. #6
    Join Date
    Apr 2008
    Posts
    4,088

    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:
      Private Sub Workbook_Open()

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

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,366,468.71636 seconds with 17 queries