Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Print Screen in VBA (Excel 2002)

    <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17> I'm full of questions today...hope i'm not frustrating you guys!?

    Hi,
    Is it possible to apply the Print Screen Key press in VBA. I would like to take the captured images of various sheets and compile them in small images on one sheet!
    I see that when I record a macro..print screen does not record as a statement! (I did foresee that, but tested it anyhow!!)

    Any help with this...(I've never used SendKeys before...is this a option...or is this only applicable to Acccess?)

    Cheers
    Regards,
    Rudi

  2. #2
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Print Screen in VBA (Excel 2002)

    Thnx Hans...
    Don't even bother explaining this macro...but it works well. <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Regards,
    Rudi

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Screen in VBA (Excel 2002)

    Edited by HansV to insert space between ( and _

    For some reason, SendKeys with {PrtSc} doesn't work. Instead, you can use

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

    Public Const VK_SNAPSHOT = &H2C

    Sub PrintScreen()
    keybd_event VK_SNAPSHOT, 0, 0, 0
    End Sub

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Screen in VBA (Excel 2002)

    What about:

    ActiveWindow.VisibleRange.CopyPicture
    (I know, it doesn't take the row and column headers and the like)
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Print Screen in VBA (Excel 2002)

    This is also a valid line of code, but I'm not keen on the its transparency...When you size it smaller, the gridlines are superimposed over the gridlines of the sheet you paste the image on, and it makes it look horrid!

    PS: With print screen I also can see the sheet tab in the image to take note of the sheet location.

    Thx for the suggestion though!
    Regards,
    Rudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •