AutoHotKey and COM cant enter text in a cell

beatified
beatified used Ask the Experts™
on
I am following Pulover's Tutorial on youtube and cant seem to get the same outcome as he does. I am trying to learn to use COM to interact with Excel at the moment. Is it possibly dependant on the version of Excel I am using vs what he used in the totorial. Is there some way to trouble shoot the issue I am having?

Here is my code... Excel is already open and a cell is selected.
XL := ComObjActive("Excel.Application")
XL.ActiveCell.Value := "Test"

Open in new window


Here is a link to the tutorial... What I am trying to achieve is demonstrated at about 7:08
Pulover's MacroCreator Tutorial
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer
Fellow 2017
Most Valuable Expert 2018
Commented:
Your question came in just as I was about to leave my office and I don't have time to spend with you now. I'll help you as soon as I get back, probably in an hour or two. In the meantime, here are a few EE threads to review (I've posted AutoHotkey code many times showing how to use COM with Excel):

https://www.experts-exchange.com/questions/28973610/AutoHotKey-vs-Pulover's-Macro-Creator-syntax.html
https://www.experts-exchange.com/questions/28952712/SSIS-extracting-data-from-excel-and-pdf-documents.html
https://www.experts-exchange.com/questions/29106430/Fill-in-web-forms-with-Excel-data.html

Of course, you'll recognize the first thread. :) We spent a lot of time on that one!

In that thread, here's the key post:
https://www.experts-exchange.com/questions/28973610/AutoHotKey-vs-Pulover's-Macro-Creator-syntax.html#a41824810

Here's a post with Excel COM at my AutoHotkey - Getting Started article:
http://www.experts-exchange.com/articles/18346/AutoHotkey-Getting-Started.html#c1733937

More later. Regards, Joe

Update: I'm back. I didn't look at the video, but your code is fine. Assign it to a hotkey and it works perfectly. For example, let's say the hotkey is Shift+F12 (of course, it can be any hotkey you want). Here's the full script, using your posted code with no changes:

+F12::
XL := ComObjActive("Excel.Application")
XL.ActiveCell.Value := "Test"
Return

Open in new window

Run that script, then click on any cell in the spreadsheet and hit Shift+F12 (or whatever hotkey you chose) — "Test" will appear in the cell. Regards, Joe

Author

Commented:
First of all thank you for your help both now and in the past I definitely remember our conversation from the past question. I really am grateful for you taking the time to help me with that one.

I think my issue was that I didn't assign a hotkey for the Script. Not positive but when I did assign it, it started working.

If your willing there is likely to be more questions to come.

BTW AHK is too steep a learning curve right now Pulover's Macro Creator makes it bearable it looks like there isn't much difference when dealing with COM but it helps me to have a tutorial to look at and a GUI is all I can handle at the moment. I wish I had a brain that worked better with programing and code but I don't yet its going to take some real practice.

Author

Commented:
Always willing to help and very friendly. Really appreciate the time Joe took for me.
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
> thank you for your help both now and in the past

You're very welcome...and thanks back to you for writing such a nice Testimonial...I really appreciate it!

> I think my issue was that I didn't assign a hotkey for the Script.

From what you describe, it sounds as if that's the case.

> when I did assign it, it started working

Glad to hear it!

> If your willing there is likely to be more questions to come.

Absolutely! Very happy to help. I'll keep an eye out for your questions.

> AHK is too steep a learning curve right now Pulover's Macro Creator makes it bearable

I can understand that, but as you know from our prior thread, I'm in the opposite camp...I never use Pulover's Macro Creator. That said, I'll do my best to help you, but sometimes (I suspect most of the time) it will be easier for me to write code for you from scratch. Regards, Joe

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial