Jump to content
Macro Express Forums

Excel resists keystrokes


Recommended Posts

Years ago I learnt some basic VBA coding and wrote many macros for my Excel 2000 (and a few for Word 2000). So when I open Excel files I usually get this message:

 

ExcelMacroWarning.jpg

 

 

and I click the Enable button or type 'e' to proceed. I work with the above spreadsheet very frequently so I thought I'd take a few minutes to eliminate that step with a hotkey macro that opens the XLS file, waits for the message and then types 'e'. But Excel obstinately refuses to accept it. I can manually type 'e' at that point, but Text Type (Simulate Keystrokes): e fails. And Tab+Enter. And a mouse click on the button.

 

Do you reckon it's because ME Pro gets 'outranked' by VBA at this stage, or something along those lines, rendering Excel impervious to anything other than manual entry?

 

When I get time I'll see if I can fumble up a a solution with Autohotkey instead.

 

Of course, I can change Excel's Security setting from Medium to Low, which prevents the message appearing, but that then applies to all files.

 

--
Terry, East Grinstead, UK

 

 

 

Link to comment
Share on other sites

Thanks Paul, no, I hadn't. But that doesn't work from TextType either.

 

Edit, Monday 23 September 2013, 10:05 UK time:

 

However, the following Autohotkey script (entirely replacing the macro) did work.

; Intended result: Open the specific spreadsheet WalkIndex.xls (with its macro warning message) and click 'e' to enable macros.
Run, "C:\Docs\My Dropbox\FinishedWalks\WalkIndex.xls"
WinWait, Microsoft Excel
Send, e


I'd like to have tested just the Send within ME Pro, but unfortunately the External Script command does not support AHK.

It does allow the use of AutoIt scripts but my know-how on that is even more limited than on AHK. I did try the following:

Program Launch: "WalkIndex.xls" (Normal)
Parameters:
Wait for Window Title: Microsoft Excel
External Script: AutoIt

where the script was simply this one line:


Send("e")


But it didn't work. (And oddly there seemed to be two of the Excel macro warning messages displayed, as I had to click 'X' twice to close them.)

Nor did this AutoIt script work:

WinWait ("Microsoft Excel")
Send("e")


(BTW, as an aside, why does ME Pro insist on having a 'console' variable?)

This standalone AutoIt script worked, typing 'e' in Notepad:

Run (@WindowsDir & "\notepad.exe")
Sleep (100)
Send("e")


So it seems to me that either my ME Pro addition is incomplete or AutoIt suffers the same issue as ME Pro, preventing keystroke entry.

 

 

--
Terry, East Grinstead, UK

Link to comment
Share on other sites

Terry it's because it's a security prompt. Like UAC they don't want someone to be able to defeat their security measures by doing exactly what you are doing.

 

I don't understand. Why are you working so hard to write a macro? Why don't you just disable that security feature? That's what I do for me and my clients.

Link to comment
Share on other sites

Terry it's because it's a security prompt. Like UAC they don't want someone to be able to defeat their security measures by doing exactly what you are doing.

 

I don't understand. Why are you working so hard to write a macro? Why don't you just disable that security feature? That's what I do for me and my clients.

 

Yes, I know, but as I mentioned in my opening post I'd rather retain some security (medium level) for the majority of files but not for the few like this one that I work with frequently.

 

Also as mentioned, my simple AHK script does the job very simply. The rest is pure curiosity and because I don't like unsolved puzzles!

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...