Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
VBA code for Screenshot
Willem Els 
   
2 years ago
Hi Richard,

Some years ago, Alex was kind enough to make a video and shared the VBA code how to take a screenshot by clicking on a button.

I search for it in the Code Vault but it is not there nor any reference to it.
I think I would be great to use it in case of an error to automatically email me/ the Screenshot when a error occur as users seams to (lie) struggle to explain the error.
Yes, I have the Logit in place but the screenshot can be used for multiple projects.

Thank you for your time.
Alex Hedley  @Reply  
           
2 years ago
Legacy Tip: Screenshot
Richard Rost  @Reply  
          
2 years ago
If you ever can't find something on the website using the search box, come all the way down to the bottom of the search results, and you'll see a Google search option that we use. Google to search my website and if you search for "screenshot," Alex's tip comes up as the first item. Google is honestly much better at indexing my site than I am; mine usually only looks at the titles of pages. Classic pages like Alex's old tips aren't indexed at all.
Kevin Yip  @Reply  
     
2 years ago
You may use an external image app such as IrfanView (named after its creator Irfan, pronounced "EAR faan"), which can capture screenshots with a command line, which you can run with the Shell() function in Access.  That way you can capture the screen with just one line of code:

     Shell """D:\Program Files\IrfanView\i_view64.exe"" /capture=0 /convert=""D:\My Pictures\test240423.jpg"""
    
The full list of command line options is under "Help" inside the IrfanView application, which also has a GUI for non-programmers.

Whenever there is a "low code" alternative, I would use it instead of calling Windows library functions, which often involves a ton of code as shown in Alex's method.
Richard Rost  @Reply  
          
2 years ago
I haven't tested this, but I asked GPT if Windows alone could do it, and apparently PowerShell has the ability to capture the screen. Here's the script it gave me, but again, I have not tested this yet, so feel free.

DetailsAdd-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

# Define the rectangle coordinates and size (X, Y, Width, Height)
$startX = 100  # X coordinate of the rectangle's top-left corner
$startY = 100  # Y coordinate of the rectangle's top-left corner
$rectWidth = 300  # Width of the rectangle
$rectHeight = 200  # Height of the rectangle

# Create a bitmap of the specified size
$bitmap = New-Object System.Drawing.Bitmap $rectWidth, $rectHeight

# Create graphics object from the bitmap
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)

# Define the screen coordinates to start from
$screenPoint = New-Object System.Drawing.Point $startX, $startY

# Capture the specific part of the screen
$graphics.CopyFromScreen($screenPoint, [System.Drawing.Point]::Empty, $rectWidth, $rectHeight)

# Save the screenshot to a file
$bitmap.Save("C:\Path\To\Save\Screenshot.png", [System.Drawing.Imaging.ImageFormat]::Png)

# Dispose of the graphics object and bitmap to free up resources
$graphics.Dispose()
$bitmap.Dispose()

Write-Output "Screenshot of the specified area saved to C:\Path\To\Save\Screenshot.png"

Willem Els OP  @Reply  
   
2 years ago
Thank you all.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 7:11:24 AM. PLT: 0s