take webcam picture from userform

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
I want to create a button that will capture a picture from the webcam on my my laptop. Just a trigger of some sort. I don't want to use the software that came with the camera if at all possible. Is this going to be really difficult? Any idea's?
 
Hello,
I was wondering if you found a better way to take a picture inside Excel? I am using this code and it works well except for the 10 second delay while the picture is being taken. My problem is the resolution is so low that I cannot blow the picture up beyond 1 X 1 inch without distorting the picture. Does anyone know how to set the resolution?
I was sent the following line from the camera developer but they cannot tell me how to insert the line:

Hello Tim,
Please try this function: SetVideoFormat
Function SetVideoFormat (width As Long, height As Long) As Boolean


Anyone know how to do this? I posted a new thread earlier today but received no responses. I am flat out stuck until I get this to work.
Thanks for any help you may give me.
Tim Knight
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

I haven't found any better coding for this. I recently was trying to look at this again too and found this snippet:

Code:
ption Explicit
Const WM_CAP As Long = &H400
Const WM_CAP_DRIVER_CONNECT As Long = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Long = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Long = WM_CAP + 30
Const WS_CHILD As Long = &H40000000
Const WS_VISIBLE As Long = &H10000000

Declare Function SendMessage Lib "User32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As _
Any) As Long

Declare Function DestroyWindow Lib "User32" (ByVal hndw As Long) As Boolean

Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
(ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Integer, ByVal hWndParent As Long, ByVal nID As _
Long) As Long

Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _
(ByVal wDriver As Integer, ByVal lpszName As String, _
ByVal cbName As Long, ByVal lpszVer As String, ByVal cbVer As Long) _
As Boolean

Declare Function GetDesktopWindow Lib "User32" () As Long

Sub WebCamClip()

Dim strName As String
Dim strVer As String
Dim hwnd As Long
Dim iDevice As Long

iDevice = 0
strName = Space(100)
strVer = Space(100)

If capGetDriverDescriptionA(iDevice, strName, 100, strVer, 100) Then

hwnd = capCreateCaptureWindowA(iDevice, WS_CHILD, 0, 0, 640, 480, _
GetDesktopWindow(), 0)

If hwnd Then

SendMessage hwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0
SendMessage hwnd, WM_CAP_EDIT_COPY, 0, 0
SendMessage hwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0

DestroyWindow hwnd
End If
End If


End Sub

This code works for me to grab one picture. It doesn't work after that though. I'm in the process of fiddling with it.
 
Upvote 0
The initial code you wrote seems to work well if I could just set the resolution in it. I see in the new script you have a resolution line. I could not get it to work though.
Thanks,
Tim
 
Upvote 0

Forum statistics

Threads
1,215,335
Messages
6,124,326
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top