[VBA] Can I make Macro Recorder to automatically start when the workbook is opened?

jerryjang99

New Member
Joined
Oct 2, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi, I was trying to catch students cheating on my finance analytics course.

So, I thought Macro Recording would be wonderful as they catch if you activated other workbooks.

I was curious if there's any method to automatically start "Record Macro" using VBA?

I mean, I wanted to start macro recorder as soon as the workbook is opened.

Thanks!!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Not sure it can be done but even if it can, you would end up with tons of irrelevant code
So, I thought Macro Recording would be wonderful as they catch if you activated other workbooks.
Best thing is to detect when other workbooks are being activated by intercepting the application events.

Add the following code to the ThisWorkbook Module:
VBA Code:
Option Explicit

Private WithEvents XlEvents As Application

Private Sub Workbook_Open()
    Set XlEvents = Application
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    If XlEvents Is Nothing Then
        Set XlEvents = Application
    End If
End Sub

Private Sub XlEvents_WorkbookActivate(ByVal Wb As Workbook)
    Debug.Print "Workbook : [" & Wb.Name & "] was activaated @ " & Format(Now, "hh:mm:ss")
End Sub

Now, each time the workbook is open, the code will start monitoring the activation of other workbooks and place the info in the immediate window.
 
Upvote 0
More to the point. Why would you want the macro recorder to turn on at workbook open???
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top