Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    E-mail a Screen Print.

    Hello!

    A couple questions... Here's what I want to happen.

    1.) The user clicks on a button in a userform.
    2.) The form automatically saves a print screen of itself.
    3.) The screen print of the userform is then e-mailed to a specified user.

    My question is, how can I do this all programatically? I can spawn my e-mail program, but what would be the best way to include a screen print?

    Any help greatly appreciated!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    The answer is YES.

    I don't have all the pieces yet, but I'm working on this. You realize you've got to put that button on every form for which you want this capability, right? Or...

    Maybe you are building a general Error Form onto which all error condition text will be displayed to the user.

    I like that idea and could use it on my project so I decided to give this some time. I've got the button click putting the active window (the form) into the clipboard. Now I just have to get the clipboard contents added as an attachment.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Groovey!

    What i've got is a form for recording issues, I figure if I just send the form, viola, instant communication! [img]/forums/images/smilies/wink.gif[/img]

    Thanks, it'll be interesting to see what you've come up with!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  4. #4
    kelliel
    Guest

    Re: E-mail a Screen Print.

    You may want to check out this link:

    <A target="_blank" HREF=http://www.allapi.net/tips/tip010.php>http://www.allapi.net/tips/tip010.php</A>

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Lawrence,

    That's too @#$% wordy for me. I don't know what Mr. Gif thinks, but if anybody I know puts that much code into a VBA app just to print the screen to the clipboard, you're fired.

    Hang on a few minutes (maybe a few hours at my current rate) and I'll have this ready. For now, here's the simpler version of El-Pasto:

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

    Private Const VK_SNAPSHOT = &H2C


    Sub ActiveWindowToClipboard()
    keybd_event VK_SNAPSHOT, 1, 0, 0
    End Sub


    Sub ScreenToClipboard()
    keybd_event VK_SNAPSHOT, 0, 0, 0
    End Sub
    </pre>



    This code compliments of Q240653
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Well, it's nothing to write home about, but it's a good first try. I wanted to paste the clipboard directly into the body of the mail message, but it's a mystery. You can't record macros in Outlook (even 2002!), so I could not see what Outlook does when you manually paste. I was therefore stuck with the document attachment approach. Recent work on other clipboard stuff (posted elsewhere, but included below) came in handy. Make a form with a Submit button and text box. Put your own error message in the text box. Don't forget the reference to the Outlook reference library.

    <pre>Sub cmdSubmit_Click()
    Dim objOutlook As Outlook.Application
    Dim nsMAPI As Outlook.NameSpace
    Dim objOutbox As Outlook.MAPIFolder
    Dim objNewMessage As Outlook.MailItem
    Dim ClipImage As Shape

    Set objOutlook = New Outlook.Application
    Set nsMAPI = objOutlook.GetNamespace("MAPI")
    Set objOutbox = nsMAPI.GetDefaultFolder(olFolderInbox)
    Set objNewMessage = objOutbox.Items.Add

    Call ClearClipboard
    Call ActiveWindowToClipboard
    Documents.Add
    Selection.Paste
    ActiveDocument.SaveAs FileName:="C:The Appplication Error"
    ActiveDocument.Close

    With objNewMessage
    .To = "Your Name Here"
    .Subject = "Error in Application -- see attached file"
    .Attachments.Add "c:The Appplication Error.doc"
    .Send
    End With
    Kill "C:The Appplication Error.doc"
    Set objOutlook = Nothing
    Set nsMAPI = Nothing
    Set objOutbox = Nothing
    Set objNewMessage = Nothing
    End Sub

    Public Declare Function EmptyClipboard Lib "user32" () As Long
    Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    Public Declare Function CloseClipboard Lib "user32" () As Long
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
    bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Const VK_SNAPSHOT = &H2C

    Sub ActiveWindowToClipboard()
    keybd_event VK_SNAPSHOT, 1, 0, 0
    End Sub

    Sub ClearClipboard()
    OpenClipboard (0)
    EmptyClipboard
    CloseClipboard
    End Sub

    </pre>

    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Okay, so I have yet to try this (rather glorious looking) code, but my bet is, I may have problems.

    My IT dept, has (rather dumbly) insisted to use Netscape Mail as opposed to Outlook. It does recognize the sendtomail command, however a reference to the outlook library will only cause problems, as hardly any users have outlook on thier machines.

    Any Ideas? [img]/forums/images/smilies/smile.gif[/img]

    Thanks Millions!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Thanks for the compliment -- glorious code indeed!

    Can you get any specs on Netscape's (Navigator/Communicator/whatever-they-call-it-now) OLE object model? Try their web site. If they support OLE, you can punch code that'll do the job (i guess, what do i know?)
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Bah.. I can't make it work...

    I figure I can work out code to paste the item into a mail message, can you please separate the code for capturing the active window and tell me where to put it? [img]/forums/images/smilies/smile.gif[/img]

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    A GifMeister is a gifmeister is a gifmeister... <img src=/S/tongue.gif border=0 alt=tongue width=15 height=15>

    Put this in the declarations part of a module, a new module just for sake of clarity:

    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
    bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Const VK_SNAPSHOT = &H2C


    Put this below the declarations part of the module

    Sub ActiveWindowToClipboard()
    keybd_event VK_SNAPSHOT, 1, 0, 0
    End Sub

    To test, just click on the above Sub and press F5.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  11. #11
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    <img src=/S/bow.gif border=0 alt=bow width=15 height=15> <img src=/S/bow.gif border=0 alt=bow width=15 height=15> <img src=/S/bow.gif border=0 alt=bow width=15 height=15> <img src=/S/bow.gif border=0 alt=bow width=15 height=15> <img src=/S/bow.gif border=0 alt=bow width=15 height=15> <img src=/S/bow.gif border=0 alt=bow width=15 height=15> <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

    Now, can we make it do just the active window, and not the entire screen? <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    That's supposed to be emulating the Alt-PrintScreen key press. Give me a few minutes/hours/days to check the function. If you've got MSDN take a look too.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  13. #13
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    I've got the whole screen, but let me tie it to a button click real quick... [img]/forums/images/smilies/wink.gif[/img]
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  14. #14
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

    It's grabbing the whole screen.. time to hit the books!

    If you find an answer before I do, feel free to post it here! Thanks for all your help Kevin!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  15. #15
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: E-mail a Screen Print.

    Where did you get the &H as a function for ALT? I'm getting 0xA5, but can't plug it in... <img src=/S/weep.gif border=0 alt=weep width=21 height=16>
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

Page 1 of 2 12 LastLast

Posting Permissions

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