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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

XL-Dennis

Well-known Member
Joined
Jul 27, 2002
Messages
1,920

ADVERTISEMENT

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
 

Chris Davison

MrExcel MVP
Joined
Feb 15, 2002
Messages
1,790
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:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,088
Messages
5,835,314
Members
430,351
Latest member
ddalton

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
Top