Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SendKeys and PrintScreen (2000)

    I'm trying to use the sendkeys function to capture a screen print of an Outlook form. So I'm using this code

    SendKeys "%{PRTSC}", True

    I'm getting this error: Type Mismatch: 'SendKeys'

    I've tried modifying so it knows that I want to hold the ALT key down while I press PRINTSCREEN like this.

    SendKeys "%({PRTSC})", True

    but got the same error.

    I read about the function in VB help and it saiad...
    Sendkeys also can't send the PRINT SCREEN key {PRTSC} to any application.

    So does that mean {PRTSC} can't be used at all with the SendKeys function?

    Thanks.
    Sarah

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

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

    Re: SendKeys and PrintScreen (2000)

    It is confusing - the list of special codes that can be used with SendKeys includes {PRTSC}, but the help explicitly states that you can't use SendKeys to send {PRTSC}. The latter is the correct statement - you can't simulate PrintScreen or Alt+PrintScreen with SendKeys <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

    Perhaps one of the many available screen capture utilities has a feature that you can use - you might ask over in the Software Finds and Wants forum.

  4. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SendKeys and PrintScreen (2000)

    Yes, the short answer is you can't. It's a bit confusing to have the information in VBA Help at all.

    OTOH you could try this tip on the Word MVP site. The API Calls section should run in Applications other than Word.

    HTH
    Grüße

  5. #4
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SendKeys and PrintScreen (2000)

    The attached code simulates pressing Alt + PrntScrn. Copy the code into a module then just Call CaptureToClipboard to capture the current window to the good ole clipboard. It works under VB6. Unfortunately I can't test it with Outlook but I can't see any reason why it shouldn't work there too.

    Regards,

    Kevin Bell

  6. #5
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SendKeys and PrintScreen (2000)

    I tried your code and it worked great in Access, but I'm getting an error when I paste it in to the script editor of an Outlook form. When I run the form I get an error that says "Script Error, Expected Statement Line No: 3" Line number 3 is the option explicit line, then if I remove that it errors on the next line.

    I'm thinking this code you suggested won't work as VBScript? I've tried moving the code before and after the code that does work.

    (I'm trying to add this print screen code to a sub that works on the print button click event. I want to take a screen shot of the open form, then I open MS Word and paste in the screen shot. The opening of Word and pasteing works. I'm just trying to get the screen shot of Outlook form to work.)

    Any ideas anyone?

    Sarah

  7. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: SendKeys and PrintScreen (2000)

    I don't think you can use Declare in a script, so you probably would need to put this in a VBA module. That would raise all sorts of other issues...

Posting Permissions

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