VBA: using SendKeys to print the screen

JaredSorensen

Board Regular
Joined
Aug 23, 2007
Messages
160
I would like to emulate hitting the Alt+Ctrl+"Print Screen" button on the keyboard with the following code. I know there are some restrictions around using the PrintScreen with the SendKeys, but I'm hoping I can still figure out how to make this work.

Following is the first part of a larger macro I've set up. If I can just get this to work, that would be perfect.

Code:
Sub PrintTheScreen()
Application.SendKeys "^%" & "PRTSC"
End Sub

Thanks.

Jared
 
Suffice it to say that there are times that I want a quick printout of what I'm working on, sometimes to mark up. I often work in large matrices which I'd never want to print out the entire 20,000 rows, however I may want to print an area of interest.

Jared
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Jared

Well couldn't you have code that prints either only the selected cells or the visible cells?
 
Upvote 0
That would certainly be an idea. Thank you.

I'm rather inexperienced in VBA; I know there are often multiple ways of getting from A to B; I usually am happy just to get something to work. Elegance is a wonderful principle for people who actually know what they're doing. : )

THanks for your suggestions.

Jared
 
Upvote 0
Jared

If you do want to take a look at what I suggest I would recommend you look at the VisibleRange, Selection, Address and PrintArea properties.

The first will return a Range object representing the visible cells.

The second will return the current selection, which will be a Range object if you've select cells.

The third will allow you to get the addresses for the 2 above.

And finally you can use that to set the print area with the 4th.
 
Upvote 0
Try this:

Code:
Sub PrintTheScreen()
Application.SendKeys "(%{1068})"
DoEvents
End Sub

Hi

This works for me however I would like to take it a step further and use the ALT + PrtScn to grab just the active window. How is this achieved ?

Thanks
Paul
 
Upvote 0

Forum statistics

Threads
1,217,408
Messages
6,136,447
Members
450,013
Latest member
k4kamal

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