Using Control to Copy Contents of a Spreadsheet in MSAccess

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tatleoat
Posts: 24
Joined: 16 Mar 2021, 14:54

Using Control to Copy Contents of a Spreadsheet in MSAccess

13 May 2021, 14:33

Hello all,

I'm trying to use some iteration of the Control command to send Ctrl+A to this spreadsheet to highlight everything, and then use Ctrl+C to copy it to the clipboard. This should be simple but for some reason nothing I'm using is working.

What my script currently does is just click the area here in the red circle and then copy it to the clipboard.
image.png
image.png (8.75 KiB) Viewed 172 times
Unfortunately doing this on different computers with different resolutions can be problematic so I want something a little more consistent. Here is the Code that I feel SHOULD work but doesn't:

Code: Select all

` & d::
Keywait, ``
SetTitleMatchMode, 2
Clipboard=
WinActivate, Material Holds / Label Printing / Relieve Material
Sleep, 100
ControlSend, OGrid1, ^a, Material Holds / Label Printing / Relieve Material
SendInput, ^c
Clipwait
Msgbox, %clipboard%
return
Below is a photo of what Window Spy shows when I have the whole grid highlighted.
image.png
image.png (29.51 KiB) Viewed 172 times
Thank you in advance
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Using Control to Copy Contents of a Spreadsheet in MSAccess

13 May 2021, 16:49

For consistency you should use COM with Access (and other MS apps). The following will copy and show the content of the current table or query in a msgbox:

Code: Select all

dmb := ComObjActive("Access.Application")                           ; use existing instance of Microsoft Access.
dmb.DoCmd.RunCommand(109)                                     	    ; select all records
dmb.DoCmd.RunCommand(190)                                           ; copy
msgbox % clipboard
14.3 & 1.3.7

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mapcarter, OrangeCat and 243 guests