Screen capture Access window and save to disk

adamgoossens

New member
Local time
Today, 15:14
Joined
May 25, 2005
Messages
8
Hi,

I'm looking to take a screen dump of the current Access window, and save it to disk, as part of the error handling for my application. Does anybody have any suggested starting points? I've been Googling around for a while, but haven't really turned up anything concrete.

This was as close as I really got (sending the print screen keystroke), however I still need a way to save this data to the disk.

Any suggestions?

Thanks,
-Adam.
 
Last edited:
Why?

Why not capture all of the relevant info about the event that the error happened in? You can save the info to a table, to a text file, send it via an email to you.

All of the above has been posted throughout this forum if you search for it.

There are freeware programs that you can run with a hot key to save the screen shot to a file. Check out www.NoNags.com for some freebies for which you could call [open] when needed.
 
ghudson said:
Why?

Why not capture all of the relevant info about the event that the error happened in? You can save the info to a table, to a text file, send it via an email to you.

I already capture all general information upon error - the Err object data and the current call stack. I don't yet have a way of capturing the data values the user was entering at the time - unless you know of anything?

By taking a screenshot I can see exactly what they were attempting to enter, and where they were at the time. I don't rely on the user to tell me this accurately, since they hardly ever do, or they can't remember :). Errors such as "The value you entered isn't valid for this field" - what value? What field? Sure, I can work it out from my call stack, but that's an ugly workaround anyway. Granted, a screenshot won't tell me exactly that info either, but I'll at least be able to look for suspect data.

I could use a 3rd party program with a hotkey, however that introduces a dependency into my application which I'd prefer not to have (I know my client wouldn't like me installing another application if I didn't need to). If I don't have another choice, however, I might either run with that or throw away the idea entirely.

When all is said and done, I think it would be something fun to do (and an excuse to see how far I could push Access/VBA as well as build my knowledge, especially on Win32 matters).

Any more ideas at all? :)

Thanks for your suggestions,
-Adam.
 
Odds are the error message box will be on top of the form and you will not be able to see exactly what the user was keying or doing.
 
Here's something you may be able to develop. I seem to rember that I used it to paste a picture from memory into Word.

I think that it will probably end up more effort than its worth though :(
Code:
' This page describes various methods in Visual Basic For Applications (VBA) for copying data to and retrieving data from the Windows clipboard.

'To copy data directly from a worksheet cell to the Windows clipboard, you can use the COPY method of the Range object, e.g., Range("A1").Copy.   However, copying other data to the clipboard, such as variable, cell comments, sheet names, etc, is not as simple as it might be.

'VBA does not give you generic PutOnClipboard or GetOffClipboard procedures, so we'll create them here. Along the way, we'll look at how VBA does interact with the Windows clipboard.

'Because these procedures use the DataObject  variable type, you must have a reference set in your VBA project to the Microsoft Forms 2.0 object library.

'Copying To The Clipboard

'To access the Windows Clipboard from VBA, you must go through an intermediate object of the DataObject type.  If your VBA procedure will be working with the clipboard, declare a NEW DataObject object with the following statement.

'Dim MyDataObj As New DataObject

'The  SetText method of the DataObject variable is used to store a text string or numeric value in the variable  For example:

'MyDataObj.SetText  "This Is A Text String"     Or
'MyDataObj.SetText 123.456

'This sets the contents of MyDataObj to a value.   To copy the contents of the variable MyDataObj to the Windows clipboard, use the PutInClipboard  method .

'MyDataObj.PutInClipboard

'Pasting From The Clipboard

'To retrieve the contents of the clipboard, use the following statement:

'MyDataObj.GetFromClipboard

'This sets the contents of MyDataObj  to the contents of the Windows clipboard.

'The counterpart to the SetText method is the GetText method.  This method returns the contents of DataObject to another variable.  For example,

'Dim MyVar As Variant
'MyVar = MyDataObj.GetText
'Because these procedures use the DataObject  variable type,
'you must have a reference set in your VBA project to the
'Microsoft Forms 2.0 object library

'  [url]http://www.cpearson.com/excel/clipboar.htm[/url]

'Using this knowledge, we can create the following VBA procedures:

Public Sub PutOnClipboard(Obj As Variant)
    Dim MyDataObj As New DataObject
    MyDataObj.SetText Format(Obj)
    MyDataObj.PutInClipboard
End Sub


Public Function GetOffClipboard() As Variant
    Dim MyDataObj As New DataObject
    
        MyDataObj.GetFromClipboard
    GetOffClipboard = MyDataObj.GetText()
End Function


Public Sub ClearClipboard()
    Dim MyDataObj As New DataObject
    MyDataObj.SetText ""
    MyDataObj.PutInClipboard
End Sub

HTH

Peter
 
I suggest that you try searching a Visual Basic forum or googling and see if somebody has already done what you ask.
 
Go here http://vbnet.mvps.org/ and search for the keyword BITMAP

You will find an article named "Mimicking the PrintScreen Function Using OLE". and that looks to do what you seach.

Post back with what you get to work for that would benefit the forum.
 
Whenever I want screen prints I use use ALT+print screen, and copy it into a word file. Clunky, but it works.

Mary
 

Users who are viewing this thread

Back
Top Bottom