![]() ![]() I tried a few different things to no avail, but overlooked the obvious: While debugging, if I put a breakpoint on ActiveSheet.Paste, I was no longer seeing the problem described above! As we both observed, the call to ActiveSheet.Paste was not actually pasting the Print Screen, but rather it was pasting whatever was previously in the Clipboard queue, to the effect that you needed to click your button to call the macro twice, before it would actually paste the screenshot. While SendKeys is notoriously flaky, if you need to use this method due to limiations of the API method described above, you might have some problems. NB: The AppActivate statement can be used to activate another (non-Excel) application and if you do this, then the keybd_event function will only capture that application, e.g AppActivate "Windows Command Processor" 'Modify as needed However, with this approach if you are using multiple monitors, it will only capture the active monitor, so further effort needs to be made if you need to capture the other monitor (this can probably be done with API calls but I haven't gotten that far). Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _īScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |