1

How to use MediaCapture or DirectShow API in MS-Access? As WIA is outdated for cameras.

WIA examples exist but not MediaCapture or DirectShow

I almost never use VBA but need to capture a photo using Access 2013. I have found a .net example by MS that looks like it will do want I need, how to get it to work in VBA in Access?

      ' Using Windows.Media.Capture.CameraCaptureUI API to capture a photo 
        Dim dialog As New CameraCaptureUI()  
        Dim file As StorageFile = Await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo) 

MS says: WIA does not support cameras in Windows Vista or later. There are lots of good examples of how to use WIA with access, but am not finding anything for MediaCapture/DirectShow API

.net MediaCapture example:

Main File: CapturePhoto.xaml.vb in

https://code.msdn.microsoft.com/windowsapps/CameraCaptureUI-Sample-845a53ac/sourcecode?fileId=43599&pathId=1212418128

.net DirectShow example:

http://www.codeproject.com/Articles/671407/Camera-Net-Library

This explains how to make available in MS Access as a DLL: A Simple C# DLL - how do I call it from Excel, Access, VBA, VB6?

June7
  • 19,874
  • 8
  • 24
  • 34
eddyparkinson
  • 3,680
  • 4
  • 26
  • 52
  • What operating system are you using? (I assume windows 8 +) – Brad Aug 20 '15 at 17:32
  • @Brad It is 8.1 Pro - but expect to upgrade to Windows 10. – eddyparkinson Aug 25 '15 at 00:36
  • 2
    http://stackoverflow.com/questions/32140725/take-a-snapshot-with-a-webcam-from-ms-access-form/32190141#32190141 – Brad Aug 25 '15 at 14:35
  • @brad using "Shell" works, but is not ideal, mostly because of detecting when the user is done with taking pictures. Any other options? One way would be DirectShow. i.e Create a DLL that works with MS access using this .net code http://www.codeproject.com/Articles/671407/Camera-Net-Library – eddyparkinson Aug 27 '15 at 00:43
  • With this approach you need to watch the `Camera Roll` folder for changes. Maybe a timer which uses FileSystemObject and caches the results then compares? It is a little easier when I did this in C# which can raise an event when a folder changes. Maybe there is a way in VBA but not sure right now. I have tried to use the DirectShow path and it is just way more complicated than it needs to be. Granted, the opening-the-camera-app route does take some user instruction (when you have finished taking your picture swipe back to your Access app) but seems like a reasonable compromise. – Brad Aug 27 '15 at 02:07
  • @brad Decided to open up a Form with just a "Taking Photos - done" on it. Then launch the camera, then pull any new pictures from Camera Roll. To pull the pictures, this gets the pictures dir =CreateObject("Shell.Application").NameSpace(&H27).Self.Path – eddyparkinson Aug 27 '15 at 02:37

0 Answers0