B1T wrote: ↑31 May 2023, 14:17
Is there any info on how to use COM related functions (not just Excel) as so far, it’s been trial and error and sifting through other code to pick up things.
VBA is the language that you can write macros with in MS Office programs. If you google VBA there will be a TON of results. It's usually pretty easy to port VBA code to AHK because "COM" is just shorthand for connecting to the same objects that VBA uses.
Most of the AHK tutorials are still written for v1.1. I would still suggest looking at them because "expressions" are largely the same in v1 and v2, and COM works exclusively with expressions. Some of the AHK functions may have changed from v1 to v2 though.
Basic Ahk_L COM Tutorial for Excel This is the tutorial many recommend for Excel basics.
MS Office COM Basics Explains COM in general. It also has links to other resources.
B1T wrote: ↑31 May 2023, 14:17
Currently using Notepad - Is there an editor that does not need installing (difficult to get software loaded onto work laptop).
The Editors section of the forum has some to choose from.
viewforum.php?f=60
Also, the AHK v2 installer gives you the option to install to the
A_Appdata folder, which does not require admin rights. Installing programs in the Windows Program Files folder requires admin rights, but I imagine you may be able to install things to other folders like A_Appdata. Some installers may request admin rights anyway, so you would need a "portable" version for those and unzip them instead of installing them.
The editor I am most familiar with is SciTE4Autohotkey. It's one of the easier editors to get working with AHK right out of the box. For a copy you don't need to install you would download the "portable (.zip)" version from the website.
viewtopic.php?f=61&t=104086 You need to unzip S4AHK in the correct folder relative to where AHK is installed (or unzipped for portable versions of AHK). If you do it properly you can switch between AHK versions within S4AHK, and when you press F1 it will open the AHK docs for the version you are using (you need to restart S4AHK if you switch versions). The way that works for me is to install (or unzip) v1, then install (or unzip) v2 to a folder named "v2" in the folder that v1 is installed. Then install (or unzip) S4AHK in the same folder that v1 is installed too.
You can look in the editors section of the forum to see if other editors have a portable version too. VS Code seems to have a .zip download.
Some editors are written in AHK, so I think you may be able to run them without installing but they are only for v1 at the time of this post as far as I know.
Quick edit and sidenote: I don't think you necessarily need COM for the task that is the subject of this thread. Comments that COM "is more reliable" are generally true, but for this task just pasting the clipboard will probably be more reliable than dealing with all the "what ifs" that COM introduces to an otherwise simple task.