Excel - This workbook contains macro

Hi there.. I am learning my ropes with KM and have already seen a few benefits, especially I use it to resize my windows and flip application over to the external monitor using "Move and Resize".

In my day to day job, I open this file in Excel quite often. When Excel opens, it prompt this window:
image

Once I clicked "Enable Macros", another window appear where I have to select my role:
image

What are the Trigger I should use and Action I should choose to automatically click "Enable Macro" and also click "Pricer" as my role?

Any help will be appreciated!

1 Like

I solved my own questions with "Press Button" and "Type a Tab Keystroke" actions (see graphic below).

But, I chose "Activates" (or Launches) as my trigger and I will get error if I switch to Excel application (or open other Excel files). It is only successful if I opened this specific file that prompts me for input.

I am alright with the error messages, unless there are more elegant way to achieve it. Appreciate any guidance.

Hi @cherry,

Assuming you already have this macro in an Excel or Office-only macro group, the two changes I'd suggest you make to your macro to make it a bit more elegant are to use a Focused Window trigger that changes when the focused window does, rather than an application activation trigger, and to engroup your macro in an If Then Else action that only runs when the initial Enable Macros button is present. This should also let you eliminate the initial 1.5 second pause from the beginning of your macro. To show what I mean with a much simpler example, if you make the changes I suggest, your macro should generally look like this:

08%20PM

1 Like

Wow, I learned so much from your one post because it didn't occur to me to set up focused window and getting KM to see if a button is present or not (I kept thinking about how to find out when a dialog box appears!) - thank you so much!

1 Like