Print screen

maddy38

New Member
Joined
Sep 22, 2002
Messages
2
Is it possible to create a macro that will automate Print screen. I have been creating macros for some time but have never been asked to do this before.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Oh dear! I have just read in Help that Sendkeys can't send the PRINT SCREEN key {PRTSC} to any application. And sure enough I could not get it to work.

So it looks like you're out of luck.
 
Upvote 0
maddy38,

Following will do the trick and place the picture in the clipboard:<pre>
Option Explicit

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Const VK_SNAPSHOT As Byte = 44

Sub test1()
'Printscreen active window
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
End Sub

Sub test2()
'Printscreen whole window
Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
End Sub</pre>

Edit:
Here´s a link to Chip Pearson site for working with the ClipBoard:
http://www.cpearson.com/excel/clipboar.htm

Funny, i VB is very simpel to save pictures from the the clipboard but not in XL.


Kind regards,
Dennis
This message was edited by XL-Dennis on 2002-09-23 06:56
 
Upvote 0
XL-Dennis said:
Following will do the trick and place the picture in the clipboard:

<pre>
Option Explicit

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Const VK_SNAPSHOT As Byte = 44

Sub test1()
'Printscreen active window
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
End Sub

</pre>

nice one Dennis...

I just used this to printscreen from an outside application into Excel and it works a treat

(wish I'd seen this at 9am instead of 5pm !)

:biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top