Solved

Access and Screen Object

Posted on 2006-06-15
15
316 Views
Last Modified: 2012-06-27
I want to include screen shot of active form in a sub report in Access. How can I automate this using VBA? I can manually do this using PrintScreen, but I want to do it with vba. Any suggestions?
0
Comment
Question by:bin2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 3
15 Comments
 

Author Comment

by:bin2003
ID: 16915858
I need help on this one!
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 100 total points
ID: 16915873
0
 

Author Comment

by:bin2003
ID: 16916421
LSMConsulting

Very good! Using this code I can copy screen to clipboard. But I am still having problems retrieving from the clipboard. The statement Me.Image1 = Clipboard.GetData(vbCFBitmap) gives me a compile error "Variable not defined"

Thanks again!!!!
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:bin2003
ID: 16916453
Thanks
0
 
LVL 85
ID: 16916463
Try CF_BITMAP
0
 

Author Comment

by:bin2003
ID: 16921862
Progress!!

However in the statement "Me.Image1.Picture = GetClipboardData(CF_BITMAP)" I get the error "MS Office can't open the File '0'. Seems like .Picture requires file name.

Help.

Thanks Again - we're getting there.
0
 
LVL 85
ID: 16922451
The Image control will require a full path to your image ... try saving the image to a file and pointing the Image control to that file. You could save this to a temp file and then delete as needed ...
0
 
LVL 58

Assisted Solution

by:harfang
harfang earned 400 total points
ID: 16922510
Hello bin2003

To write into an image, you need the PictureData property, not Picture (which expects a file name). However, I'm not sure at all that the clipboard's picture format is compatible with the Access PictureData property of image controls...

You could also select an unbound object frame and use "RunCommand acCmdPaste". This would enable all the normal conversion operations that occure during copy-paste operations.

Good luck!
(°v°)
0
 

Author Comment

by:bin2003
ID: 16930664
Still having problems saving to file.

I can copy screen to clipboard. I can save an image to a file.

How do I get image from clipboard to image?

GetClipboardData(CF_BITMAP) seems to return a Long value that is the handle of the image. How do I get the image????

Thanks for ALL HELP!!

0
 

Author Comment

by:bin2003
ID: 16935306
I still need help on this step.

Thanks!!
0
 

Author Comment

by:bin2003
ID: 16938713
How do I save it to a file??

Thanks
0
 
LVL 58

Expert Comment

by:harfang
ID: 16938764
bin2003

I played around a little bit with these bitmaps, but it's really too hard using VB. Unless you are a true guru like Stephen Lebans, who would be able to pull this off. See for example:
http://www.lebans.com/windowtobitmap.htm

The return value of GetClipboardData is of course a long pointer to the bitmap image in memory. You could get that, transform it into a string and feed that to a .PictureData property. Unluckily, this is all very hard to accomplish in VB (probably a single line of code in C)...

I tried this for you:
 • create a table "zstblSnapshot" with a single ole field "Bitmap"
 • insert a single record, prefilled with a simple bitmap.
 • create a form with some stuff and a button cmdSmile (to take the picture)
 • use zstblSnapshot as Record source, with AllowDeletions:No and AllowAdditions:No
 • drag Bitmap to the form, rename to bofBitmap and make invisible
 • create a report showing zstblSnapshot.Bitmap, and nothing else: rptSnapshot
 • use this event for cmdSmile:

Private Sub cmdSmile_Click()
    ScreenDump Me.Hwnd
    bofBitmap.Visible = True
    bofBitmap.SetFocus
    RunCommand acCmdPaste
    RunCommand acCmdSaveRecord
    cmdSmile.SetFocus
    bofBitmap.Visible = False
    DoCmd.OpenReport "rptSnapshot", acViewPreview
End Sub

ScreenDump is the function from MS that LSMC was kind enough to provide. The only change I made to it was to accept a window handle so that it would print only the form, not the entire Access window.

Anyway, this works to specifications: take a snapshot of a form and show it in a report. You can use the report as subreport if needed, naturally. Likewise, you can paste into zstblSnapshot.Bitmap in a separate form, in a subform, etc. so as not to disrupt your current GUI.

Cheers!

(°v°)
0
 
LVL 58

Expert Comment

by:harfang
ID: 16938775
> How do I save it to a file??
Study S.Lebans' code long enough, and you might find the way to do that. I didn't and haven't...
This is really quite hard without a good manual at hand and without a true system oriented programming language, no?

(°v°)
0
 

Author Comment

by:bin2003
ID: 16956195
Thank You - harfang and LSMConsulting!!!

Works great - I sure wish I had more points (apparently 500 is max).

You saved me, I never could have comleted this without your help.

Thanks again.
0
 
LVL 58

Expert Comment

by:harfang
ID: 16956467
I'm glad it worked. Success with your project!
(°v°)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question